gohbase

package module
v0.0.0-...-3e5fca4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

README

Golang HBase client Build Status codecov.io GoDoc

This is a pure-Go client for HBase.

Current status: prototype.

Supported Versions

HBase >= 1.0

Installation

go get github.com/tsuna/gohbase

Example Usage

Create a client
client := gohbase.NewClient("localhost")
Insert a cell
// Values maps a ColumnFamily -> Qualifiers -> Values.
values := map[string]map[string][]byte{"cf": map[string][]byte{"a": []byte{0}}}
putRequest, err := hrpc.NewPutStr(context.Background(), "table", "key", values)
rsp, err := client.Put(putRequest)
Get an entire row
getRequest, err := hrpc.NewGetStr(context.Background(), "table", "row")
getRsp, err := client.Get(getRequest)
Get a specific cell
// Perform a get for the cell with key "15", column family "cf" and qualifier "a"
family := map[string][]string{"cf": []string{"a"}}
getRequest, err := hrpc.NewGetStr(context.Background(), "table", "15",
    hrpc.Families(family))
getRsp, err := client.Get(getRequest)
Get a specific cell with a filter
pFilter := filter.NewKeyOnlyFilter(true)
family := map[string][]string{"cf": []string{"a"}}
getRequest, err := hrpc.NewGetStr(context.Background(), "table", "15",
    hrpc.Families(family), hrpc.Filters(pFilter))
getRsp, err := client.Get(getRequest)
Scan with a filter
pFilter := filter.NewPrefixFilter([]byte("7"))
scanRequest, err := hrpc.NewScanStr(context.Background(), "table",
		hrpc.Filters(pFilter))
scanRsp, err := client.Scan(scanRequest)

Contributing

Any help would be appreciated. Please use GerritHub to send changes for review, instead of GitHub pull requests. Please sign the Contributor License Agreement when you send your first change for review.

License

Copyright © 2015 The GoHBase Authors. All rights reserved. Use of this source code is governed by the Apache License 2.0 that can be found in the COPYING file.

Documentation

Index

Constants

View Source
const (
	StandardClient = iota
	AdminClient
)

Variables

View Source
var (

	// ErrDeadline is returned when the deadline of a request has been exceeded
	ErrDeadline = errors.New("deadline exceeded")

	// TableNotFound is returned when attempting to access a table that
	// doesn't exist on this cluster.
	TableNotFound = errors.New("table not found")
)

Constants

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client provides access to an HBase cluster.

func NewClient

func NewClient(zkquorum string, options ...Option) *Client

NewClient creates a new HBase client.

func (*Client) CheckTable

func (c *Client) CheckTable(ctx context.Context, table string) error

CheckTable returns an error if the given table name doesn't exist.

func (*Client) Scan

func (c *Client) Scan(s *hrpc.Scan) ([]*hrpc.Result, error)

Scan retrieves the values specified in families from the given range.

func (*Client) SendRPC

func (c *Client) SendRPC(rpc hrpc.Call) (*hrpc.Result, error)

type Option

type Option func(*Client)

func Admin

func Admin() Option

func FlushInterval

func FlushInterval(interval time.Duration) Option

FlushInterval will return an option that will set the timeout for flushing the RPC queues used in a given client

func RpcQueueSize

func RpcQueueSize(size int) Option

RpcQueueSize will return an option that will set the size of the RPC queues used in a given client

func SetMaster

func SetMaster(master zk.ResourceName) Option

Options for specifying master resource name (e.g. "/hbase/master")

func SetMeta

func SetMeta(meta zk.ResourceName) Option

Options for specifying meta resource name (e.g. "/hbase/meta-region-server")

Directories

Path Synopsis
cmd
cli
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.
Package regioninfo contains data structures to represent HBase regions.
Package regioninfo contains data structures to represent HBase regions.
Package zk encapsulates our interactions with ZooKeeper.
Package zk encapsulates our interactions with ZooKeeper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL