gohbase

package module
v0.0.0-...-9c19712 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

README

Golang HBase client Build Status codecov.io GoDoc

This is a pure Go client for HBase.

Current status: beta.

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 Github pull requests to send changes for review. 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

This section is empty.

Variables

View Source
var (

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

	// ErrRegionUnavailable is returned when sending rpc to a region that is unavailable
	ErrRegionUnavailable = errors.New("region unavailable")

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

	// ErrCannotFindRegion is returned when it took too many tries to find a
	// region for the request. It's likely that hbase:meta has overlaps or some other
	// inconsistency.
	ErrConnotFindRegion = errors.New("cannot find region for the rpc")

	// ErrMetaLookupThrottled is returned when a lookup for the rpc's region
	// has been throttled.
	ErrMetaLookupThrottled = errors.New("lookup to hbase:meta has been throttled")
)

Constants

Functions

func NewParallelScanner

func NewParallelScanner(c *client, rpc *hrpc.Scan, parallel int) hrpc.Scanner

Types

type AdminClient

type AdminClient interface {
	CreateTable(t *hrpc.CreateTable) error
	DeleteTable(t *hrpc.DeleteTable) error
	EnableTable(t *hrpc.EnableTable) error
	DisableTable(t *hrpc.DisableTable) error
	ClusterStatus() (*pb.ClusterStatus, error)
}

AdminClient to perform admistrative operations with HMaster

func NewAdminClient

func NewAdminClient(zkquorum string, options ...Option) AdminClient

NewAdminClient creates an admin HBase client.

type Client

type Client interface {
	Scan(s *hrpc.Scan) hrpc.Scanner
	ScanParallel(s *hrpc.Scan, parallel int) hrpc.Scanner
	Get(g *hrpc.Get) (*hrpc.Result, error)
	Put(p *hrpc.Mutate) (*hrpc.Result, error)
	Delete(d *hrpc.Mutate) (*hrpc.Result, error)
	Append(a *hrpc.Mutate) (*hrpc.Result, error)
	Increment(i *hrpc.Mutate) (int64, error)
	IncrementMulti(i *hrpc.Mutate) (map[string]map[string]int64, error)
	CheckAndPut(p *hrpc.Mutate, family string, qualifier string,
		expectedValue []byte) (bool, error)
	Close()
}

Client a regular HBase client

func NewClient

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

NewClient creates a new HBase client.

type Option

type Option func(*client)

func EffectiveUser

func EffectiveUser(user string) Option

EffectiveUser will return an option that will set the user used when accessing regions.

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 RegionLookupTimeout

func RegionLookupTimeout(to time.Duration) Option

RegionLookupTimeout will return an option that sets the region lookup timeout

func RegionReadTimeout

func RegionReadTimeout(to time.Duration) Option

RegionReadTimeout will return an option that sets the region read timeout

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 ZookeeperRoot

func ZookeeperRoot(root string) Option

ZookeeperRoot will return an option that will set the zookeeper root path used in a given client.

func ZookeeperTimeout

func ZookeeperTimeout(to time.Duration) Option

ZookeeperTimeout will return an option that will set the zookeeper session timeout.

type RPCClient

type RPCClient interface {
	SendRPC(rpc hrpc.Call) (proto.Message, error)
}

RPCClient is core client of gohbase. It's exposed for testing.

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.
Package region contains data structures to represent HBase regions.
Package region 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