aliexhbase

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 13 Imported by: 0

README

aliexhbase

阿里的增强版hbase客户端,使用thrift连接,提供连接池

本项目提供了两个工具

  • 客户端对象,需要导入github.com/Golang-Tools/aliexhbase,使用New函数创建一个客户端,其参数可以参考options中的定义.
  • 代理对象,需要导入github.com/Golang-Tools/aliexhbase/proxy,使用New函数创建,用对象的Init方法初始化,其参数可以参考options中的定义.同时提供对象DB作为默认的代理对象.

除了上面得对象外还提供了接口UniversalClient用于描述上面的2个对象.

Documentation

Overview

客户端定义

hbase连接定义

常量定义

异常定义

初始化配置项

连接池定义

接口定义

Index

Constants

View Source
const (
	DEFAULT_CHECKINTERVAL      = 120 //清除超时连接间隔
	MaxInitConnCount           = 10
	DEFAULT_POOL_CLOSE_TIMEOUT = time.Duration(1) * time.Second
)

Variables

View Source
var (
	//ErrOverMax ThriftPool 连接超过设置的最大连接数
	ErrOverMax = errors.New("ThriftPool 连接超过设置的最大连接数")
	//ErrInvalidConn ThriftPool Client回收时变成nil
	ErrInvalidConn = errors.New("ThriftPool Client回收时变成nil")
	//ErrPoolClosed ThriftPool 连接池已经被关闭
	ErrPoolClosed = errors.New("ThriftPool 连接池已经被关闭")
	//ErrPoolAlreadyOpened ThriftPool 连接池已经被打开
	ErrPoolAlreadyOpened = errors.New("ThriftPool 连接池已经被打开")
	//ErrSocketDisconnect ThriftPool 客户端socket连接已断开
	ErrSocketDisconnect = errors.New("ThriftPool 客户端socket连接已断开")
	//ErrClientPWDNotSet Client 未设置密码
	ErrClientPWDNotSet = errors.New("Client 未设置密码")
	//ErrClientCreateParamsNotEnough Client 对象创建参数不全
	ErrClientCreateParamsNotEnough = errors.New("Client 对象创建参数不全")
	//ErrClientPoolNotSet Client 未设置连接池
	ErrClientPoolNotSet = errors.New("Client 未设置连接池")
)

error

View Source
var DefaultOptions = Options{
	Poolconfig: &ThriftPoolConfig{
		MaxConn: 60,

		ConnTimeout: time.Second * 2,

		IdleTimeout: time.Minute * 15,

		Timeout: time.Second * 5,

		Interval: time.Millisecond * 50,
	},
	Logger: logrus.New().WithField("logger", "aliexhbase"),
}

Functions

This section is empty.

Types

type Client

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

func New

func New(opts ...Option) (*Client, error)

func (*Client) AddColumnFamily

func (p *Client) AddColumnFamily(ctx context.Context, tableName *hbase.TTableName, column *hbase.TColumnFamilyDescriptor) error

Add a column family to an existing table. Synchronous operation.

Parameters:

  • TableName: the tablename to add column family to
  • Column: column family descriptor of column family to be added

func (*Client) Append

func (p *Client) Append(ctx context.Context, table []byte, tappend *hbase.TAppend) (*hbase.TResult_, error)

Parameters:

  • Table: the table to append the value on
  • Tappend: the TAppend to append

func (*Client) CheckAndDelete

func (p *Client) CheckAndDelete(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, value []byte, tdelete *hbase.TDelete) (bool, error)

Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the delete.

@return true if the new delete was executed, false otherwise

Parameters:

  • Table: to check in and delete from
  • Row: row to check
  • Family: column family to check
  • Qualifier: column qualifier to check
  • Value: the expected value, if not provided the

check is for the non-existence of the column in question

  • Tdelete: the TDelete to execute if the check succeeds

func (*Client) CheckAndMutate

func (p *Client) CheckAndMutate(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, compareOp hbase.TCompareOp, value []byte, rowMutations *hbase.TRowMutations) (bool, error)

Atomically checks if a row/family/qualifier value matches the expected value. If it does, it mutates the row.

@return true if the row was mutated, false otherwise

Parameters:

  • Table: to check in and delete from
  • Row: row to check
  • Family: column family to check
  • Qualifier: column qualifier to check
  • CompareOp: comparison to make on the value
  • Value: the expected value to be compared against, if not provided the

check is for the non-existence of the column in question

  • RowMutations: row mutations to execute if the value matches

func (*Client) CheckAndPut

func (p *Client) CheckAndPut(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, value []byte, tput *hbase.TPut) (bool, error)

Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the TPut.

@return true if the new put was executed, false otherwise

Parameters:

  • Table: to check in and put to
  • Row: row to check
  • Family: column family to check
  • Qualifier: column qualifier to check
  • Value: the expected value, if not provided the

check is for the non-existence of the column in question

  • Tput: the TPut to put if the check succeeds

func (*Client) Close

func (c *Client) Close() error

Close 关闭客户端,默认如果设置请求超时则等待一个请求超时的时间,否则等待1s

func (*Client) CloseScanner

func (p *Client) CloseScanner(ctx context.Context, scannerId int32) error

Closes the scanner. Should be called to free server side resources timely. Typically close once the scanner is not needed anymore, i.e. after looping over it to get all the required rows.

Parameters:

  • ScannerId: the Id of the Scanner to close *

func (*Client) CreateNamespace

func (p *Client) CreateNamespace(ctx context.Context, namespaceDesc *hbase.TNamespaceDescriptor) error

Create a new namespace. Blocks until namespace has been successfully created or an exception is thrown

Parameters:

  • NamespaceDesc: descriptor which describes the new namespace

func (*Client) CreateTable

func (p *Client) CreateTable(ctx context.Context, desc *hbase.TTableDescriptor, splitKeys [][]byte) error

Creates a new table with an initial set of empty regions defined by the specified split keys. The total number of regions created will be the number of split keys plus one. Synchronous operation.

Parameters:

  • Desc: table descriptor for table
  • SplitKeys: rray of split keys for the initial regions of the table

func (*Client) DeleteColumnFamily

func (p *Client) DeleteColumnFamily(ctx context.Context, tableName *hbase.TTableName, column []byte) error

Delete a column family from a table. Synchronous operation.

Parameters:

  • TableName: the tablename to delete column family from
  • Column: name of column family to be deleted

func (*Client) DeleteMultiple

func (p *Client) DeleteMultiple(ctx context.Context, table []byte, tdeletes []*hbase.TDelete) ([]*hbase.TDelete, error)

Bulk commit a List of TDeletes to the table.

Throws a TIOError if any of the deletes fail.

Always returns an empty list for backwards compatibility.

Parameters:

  • Table: the table to delete from
  • Tdeletes: list of TDeletes to delete

func (*Client) DeleteNamespace

func (p *Client) DeleteNamespace(ctx context.Context, name string) error

Delete an existing namespace. Only empty namespaces (no tables) can be removed. Blocks until namespace has been successfully deleted or an exception is thrown.

Parameters:

  • Name: namespace name

func (*Client) DeleteSingle

func (p *Client) DeleteSingle(ctx context.Context, table []byte, tdelete *hbase.TDelete) error

Deletes as specified by the TDelete.

Note: "delete" is a reserved keyword and cannot be used in Thrift thus the inconsistent naming scheme from the other functions.

Parameters:

  • Table: the table to delete from
  • Tdelete: the TDelete to delete

func (*Client) DeleteTable

func (p *Client) DeleteTable(ctx context.Context, tableName *hbase.TTableName) error

Deletes a table. Synchronous operation.

Parameters:

  • TableName: the tablename to delete

func (*Client) DisableTable

func (p *Client) DisableTable(ctx context.Context, tableName *hbase.TTableName) error

Disable a table

Parameters:

  • TableName: the tablename to disable

func (*Client) EnableTable

func (p *Client) EnableTable(ctx context.Context, tableName *hbase.TTableName) error

Enalbe a table

Parameters:

  • TableName: the tablename to enable

func (*Client) Exists

func (p *Client) Exists(ctx context.Context, table []byte, tget *hbase.TGet) (bool, error)

Test for the existence of columns in the table, as specified in the TGet.

@return true if the specified TGet matches one or more keys, false if not

Parameters:

  • Table: the table to check on
  • Tget: the TGet to check for

func (*Client) ExistsAll

func (p *Client) ExistsAll(ctx context.Context, table []byte, tgets []*hbase.TGet) ([]bool, error)

Test for the existence of columns in the table, as specified by the TGets.

This will return an array of booleans. Each value will be true if the related Get matches one or more keys, false if not.

Parameters:

  • Table: the table to check on
  • Tgets: a list of TGets to check for

func (*Client) Get

func (p *Client) Get(ctx context.Context, table []byte, tget *hbase.TGet) (*hbase.TResult_, error)

Method for getting data from a row.

If the row cannot be found an empty Result is returned. This can be checked by the empty field of the TResult

@return the result

Parameters:

  • Table: the table to get from
  • Tget: the TGet to fetch

func (*Client) GetAllRegionLocations

func (p *Client) GetAllRegionLocations(ctx context.Context, table []byte) ([]*hbase.THRegionLocation, error)

Get all of the region locations for a given table.

Parameters:

  • Table

func (*Client) GetMultiple

func (p *Client) GetMultiple(ctx context.Context, table []byte, tgets []*hbase.TGet) ([]*hbase.TResult_, error)

Method for getting multiple rows.

If a row cannot be found there will be a null value in the result list for that TGet at the same position.

So the Results are in the same order as the TGets.

Parameters:

  • Table: the table to get from
  • Tgets: a list of TGets to fetch, the Result list

will have the Results at corresponding positions or null if there was an error

func (*Client) GetNamespaceDescriptor

func (p *Client) GetNamespaceDescriptor(ctx context.Context, name string) (*hbase.TNamespaceDescriptor, error)

Get a namespace descriptor by name. @retrun the descriptor

Parameters:

  • Name: name of namespace descriptor

func (*Client) GetRegionLocation

func (p *Client) GetRegionLocation(ctx context.Context, table []byte, row []byte, reload bool) (*hbase.THRegionLocation, error)

Given a table and a row get the location of the region that would contain the given row key.

reload = true means the cache will be cleared and the location will be fetched from meta.

Parameters:

  • Table
  • Row
  • Reload

func (*Client) GetScannerResults

func (p *Client) GetScannerResults(ctx context.Context, table []byte, tscan *hbase.TScan, numRows int32) ([]*hbase.TResult_, error)

Get results for the provided TScan object. This helper function opens a scanner, get the results and close the scanner.

@return between zero and numRows TResults

Parameters:

  • Table: the table to get the Scanner for
  • Tscan: the scan object to get a Scanner for
  • NumRows: number of rows to return

func (*Client) GetScannerRows

func (p *Client) GetScannerRows(ctx context.Context, scannerId int32, numRows int32) ([]*hbase.TResult_, error)

Grabs multiple rows from a Scanner.

@return Between zero and numRows TResults

Parameters:

  • ScannerId: the Id of the Scanner to return rows from. This is an Id returned from the openScanner function.
  • NumRows: number of rows to return

func (*Client) GetTableDescriptor

func (p *Client) GetTableDescriptor(ctx context.Context, table *hbase.TTableName) (*hbase.TTableDescriptor, error)

Get a table descriptor. @return the TableDescriptor of the giving tablename

Parameters:

  • Table: the tablename of the table to get tableDescriptor

func (*Client) GetTableDescriptors

func (p *Client) GetTableDescriptors(ctx context.Context, tables []*hbase.TTableName) ([]*hbase.TTableDescriptor, error)

Get table descriptors of tables. @return the TableDescriptor of the giving tablename

Parameters:

  • Tables: the tablename list of the tables to get tableDescriptor

func (*Client) GetTableDescriptorsByNamespace

func (p *Client) GetTableDescriptorsByNamespace(ctx context.Context, name string) ([]*hbase.TTableDescriptor, error)

Get table descriptors of tables in the given namespace @return the tableDescriptors in the namespce

Parameters:

  • Name: The namesapce's name

func (*Client) GetTableDescriptorsByPattern

func (p *Client) GetTableDescriptorsByPattern(ctx context.Context, regex string, includeSysTables bool) ([]*hbase.TTableDescriptor, error)

Get table descriptors of tables that match the given pattern @return the tableDescriptors of the matching table

Parameters:

  • Regex: The regular expression to match against
  • IncludeSysTables: set to false if match only against userspace tables

func (*Client) GetTableNamesByNamespace

func (p *Client) GetTableNamesByNamespace(ctx context.Context, name string) ([]*hbase.TTableName, error)

Get table names of tables in the given namespace @return the table names of the matching table

Parameters:

  • Name: The namesapce's name

func (*Client) GetTableNamesByPattern

func (p *Client) GetTableNamesByPattern(ctx context.Context, regex string, includeSysTables bool) ([]*hbase.TTableName, error)

Get table names of tables that match the given pattern @return the table names of the matching table

Parameters:

  • Regex: The regular expression to match against
  • IncludeSysTables: set to false if match only against userspace tables

func (*Client) HardClose

func (c *Client) HardClose() error

HardClose 强制关闭客户端

func (*Client) Increment

func (p *Client) Increment(ctx context.Context, table []byte, tincrement *hbase.TIncrement) (*hbase.TResult_, error)

Parameters:

  • Table: the table to increment the value on
  • Tincrement: the TIncrement to increment

func (*Client) IsOpen

func (c *Client) IsOpen() bool

IsOpen 判断客户端是否已经开启

func (*Client) IsTableAvailable

func (p *Client) IsTableAvailable(ctx context.Context, tableName *hbase.TTableName) (bool, error)

@return true if table is available, false if not

Parameters:

  • TableName: the tablename to check

func (*Client) IsTableAvailableWithSplit

func (p *Client) IsTableAvailableWithSplit(ctx context.Context, tableName *hbase.TTableName, splitKeys [][]byte) (bool, error)
  • Use this api to check if the table has been created with the specified number of splitkeys
  • which was used while creating the given table. Note : If this api is used after a table's
  • region gets splitted, the api may return false. *
  • @return true if table is available, false if not

*

Parameters:

  • TableName: the tablename to check
  • SplitKeys: keys to check if the table has been created with all split keys

func (*Client) IsTableDisabled

func (p *Client) IsTableDisabled(ctx context.Context, tableName *hbase.TTableName) (bool, error)

@return true if table is disabled, false if not

Parameters:

  • TableName: the tablename to check

func (*Client) IsTableEnabled

func (p *Client) IsTableEnabled(ctx context.Context, tableName *hbase.TTableName) (bool, error)

@return true if table is enabled, false if not

Parameters:

  • TableName: the tablename to check

func (*Client) ListNamespaceDescriptors

func (p *Client) ListNamespaceDescriptors(ctx context.Context) ([]*hbase.TNamespaceDescriptor, error)

@return all namespaces

func (*Client) ModifyColumnFamily

func (p *Client) ModifyColumnFamily(ctx context.Context, tableName *hbase.TTableName, column *hbase.TColumnFamilyDescriptor) error

Modify an existing column family on a table. Synchronous operation.

Parameters:

  • TableName: the tablename to modify column family
  • Column: column family descriptor of column family to be modified

func (*Client) ModifyNamespace

func (p *Client) ModifyNamespace(ctx context.Context, namespaceDesc *hbase.TNamespaceDescriptor) error

Modify an existing namespace. Blocks until namespace has been successfully modified or an exception is thrown

Parameters:

  • NamespaceDesc: descriptor which describes the new namespace

func (*Client) ModifyTable

func (p *Client) ModifyTable(ctx context.Context, desc *hbase.TTableDescriptor) error

Modify an existing table

Parameters:

  • Desc: the descriptor of the table to modify

func (*Client) MutateRow

func (p *Client) MutateRow(ctx context.Context, table []byte, trowMutations *hbase.TRowMutations) error

mutateRow performs multiple mutations atomically on a single row.

Parameters:

  • Table: table to apply the mutations
  • TrowMutations: mutations to apply

func (*Client) NewCtx

func (c *Client) NewCtx() (ctx context.Context, cancel context.CancelFunc)

NewCtx 根据注册的超时时间构造一个上下文

func (*Client) Open

func (c *Client) Open() error

Open 开启客户端

func (*Client) OpenScanner

func (p *Client) OpenScanner(ctx context.Context, table []byte, tscan *hbase.TScan) (int32, error)

Get a Scanner for the provided TScan object.

@return Scanner Id to be used with other scanner procedures

Parameters:

  • Table: the table to get the Scanner for
  • Tscan: the scan object to get a Scanner for

func (*Client) Put

func (p *Client) Put(ctx context.Context, table []byte, tput *hbase.TPut) error

Commit a TPut to a table.

Parameters:

  • Table: the table to put data in
  • Tput: the TPut to put

func (*Client) PutMultiple

func (p *Client) PutMultiple(ctx context.Context, table []byte, tputs []*hbase.TPut) error

Commit a List of Puts to the table.

Parameters:

  • Table: the table to put data in
  • Tputs: a list of TPuts to commit

func (*Client) SoftClose

func (c *Client) SoftClose(timeout time.Duration) error

SoftClose 设置等待时长以软关闭客户端

func (*Client) TableExists

func (p *Client) TableExists(ctx context.Context, tableName *hbase.TTableName) (bool, error)

@return true if table exists already, false if not

Parameters:

  • TableName: the tablename of the tables to check

func (*Client) TruncateTable

func (p *Client) TruncateTable(ctx context.Context, tableName *hbase.TTableName, preserveSplits bool) error

Truncate a table. Synchronous operation.

Parameters:

  • TableName: the tablename to truncate
  • PreserveSplits: whether to preserve previous splits

type Conn

type Conn struct {
	// 真正的Thrift客户端,业务创建传入
	*hbase.THBaseServiceClient
	// contains filtered or unexported fields
}

func NewConn

func NewConn(addr, user, passwd string) (*Conn, error)

func (*Conn) Check

func (c *Conn) Check() bool

检测连接是否有效

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) IsOpen

func (c *Conn) IsOpen() bool

func (*Conn) Open

func (c *Conn) Open() error

type Option

type Option interface {
	Apply(*Options)
}

Option configures how we set up the connection.

func WithConnTimeoutS

func WithConnTimeoutS(ConnTimeoutS int) Option

WithConnTimeoutS 创建连接超时时间,单位s

func WithIdleTimeoutS

func WithIdleTimeoutS(IdleTimeoutS int) Option

WithIdleTimeoutS 空闲客户端超时时间,超时主动释放连接,关闭客户端,单位s

func WithIntervalMS

func WithIntervalMS(IntervalMS int) Option

WithIntervalMS 获取Thrift客户端失败重试间隔,单位ms

func WithLogger

func WithLogger(logger logrus.FieldLogger) Option

WithLogger 指定使用logger

func WithMaxConns

func WithMaxConns(MaxConns int32) Option

WithMaxOpenConns 设置连接池的最大连接数

func WithOptions

func WithOptions(opts *Options) Option

WithOption 设置option

func WithParallelCallback

func WithParallelCallback() Option

WithParallelCallback 只对proxy有效,设置初始化后回调并行执行而非串行执行

func WithQueryTimeoutMS

func WithQueryTimeoutMS(QueryTimeout int) Option

WithQueryTimeoutMS 设置最大请求超时,单位ms

func WithTimeoutS

func WithTimeoutS(TimeoutS int) Option

WithTimeoutS 获取Thrift客户端超时时间,单位s

func WithURL

func WithURL(URL string) Option

WithURL 使用要连接的数据库管理系统的url,注意必须有用户名和密码,也就是说形式为`http:\\user:pwd@host:port`

type Options

type Options struct {
	// Thrfit Server端地址
	Poolconfig       *ThriftPoolConfig
	QueryTimeout     time.Duration
	Logger           logrus.FieldLogger
	Parallelcallback bool
}

Options 客户端配置

type PoolStatus

type PoolStatus uint32

PoolStatus 池状态

const (
	PoolStatus_Stoped PoolStatus = iota
	PoolStatus_Open
)

type ThriftPool

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

Thrift客户端连接池

func NewThriftPool

func NewThriftPool(config *ThriftPoolConfig) *ThriftPool

NewThriftPool 创建一个新的池对象

func (*ThriftPool) CheckTimeout

func (p *ThriftPool) CheckTimeout()

CheckTimeout 检查池中是否有超时的空闲连接,有的话关闭

func (*ThriftPool) ClearConn

func (p *ThriftPool) ClearConn()

ClearConn 定时清空闲置连接

func (*ThriftPool) CloseConn

func (p *ThriftPool) CloseConn(client *Conn)

CloseConn 关闭指定连接

func (*ThriftPool) Get

func (p *ThriftPool) Get() (*Conn, error)

获取Thrift空闲连接

func (*ThriftPool) GetConnCount

func (p *ThriftPool) GetConnCount() int32

GetConnCount 获取当前连接数

func (*ThriftPool) GetIdleCount

func (p *ThriftPool) GetIdleCount() uint32

GetIdleCount 获取现在闲置连接个数

func (*ThriftPool) IsOpen

func (p *ThriftPool) IsOpen() bool

IsOpen 查看池是否开着

func (*ThriftPool) Put

func (p *ThriftPool) Put(client *Conn) error

Put 归还Thrift客户端

func (*ThriftPool) Reconnect

func (p *ThriftPool) Reconnect(client *Conn) (newClient *Conn, err error)

关闭有问题的连接,并创建新的连接

func (*ThriftPool) Recover

func (p *ThriftPool) Recover()

Recover 恢复连接池

func (*ThriftPool) Release

func (p *ThriftPool) Release()

Release 释放连接池

type ThriftPoolConfig

type ThriftPoolConfig struct {
	// Thrfit Server端地址
	Addr   string
	User   string
	Passwd string
	// 最大连接数
	MaxConn int32
	// 创建连接超时时间
	ConnTimeout time.Duration
	// 空闲客户端超时时间,超时主动释放连接,关闭客户端
	IdleTimeout time.Duration
	// 获取Thrift客户端超时时间
	Timeout time.Duration
	// 获取Thrift客户端失败重试间隔
	Interval time.Duration
}

连接池配置

type UniversalClient

type UniversalClient interface {
	// Test for the existence of columns in the table, as specified in the TGet.
	//
	// @return true if the specified TGet matches one or more keys, false if not
	//
	// Parameters:
	//  - Table: the table to check on
	//  - Tget: the TGet to check for
	Exists(context.Context, []byte, *hbase.TGet) (bool, error)

	// Test for the existence of columns in the table, as specified by the TGets.
	//
	// This will return an array of booleans. Each value will be true if the related Get matches
	// one or more keys, false if not.
	//
	// Parameters:
	//  - Table: the table to check on
	//  - Tgets: a list of TGets to check for
	ExistsAll(context.Context, []byte, []*hbase.TGet) ([]bool, error)

	// Method for getting data from a row.
	//
	// If the row cannot be found an empty Result is returned.
	// This can be checked by the empty field of the TResult
	//
	// @return the result
	//
	// Parameters:
	//  - Table: the table to get from
	//  - Tget: the TGet to fetch
	Get(context.Context, []byte, *hbase.TGet) (*hbase.TResult_, error)
	// Method for getting multiple rows.
	//
	// If a row cannot be found there will be a null
	// value in the result list for that TGet at the
	// same position.
	//
	// So the Results are in the same order as the TGets.
	//
	// Parameters:
	//  - Table: the table to get from
	//  - Tgets: a list of TGets to fetch, the Result list
	// will have the Results at corresponding positions
	// or null if there was an error
	GetMultiple(context.Context, []byte, []*hbase.TGet) ([]*hbase.TResult_, error)

	// Commit a TPut to a table.
	//
	// Parameters:
	//  - Table: the table to put data in
	//  - Tput: the TPut to put
	Put(context.Context, []byte, *hbase.TPut) error

	// Atomically checks if a row/family/qualifier value matches the expected
	// value. If it does, it adds the TPut.
	//
	// @return true if the new put was executed, false otherwise
	//
	// Parameters:
	//  - Table: to check in and put to
	//  - Row: row to check
	//  - Family: column family to check
	//  - Qualifier: column qualifier to check
	//  - Value: the expected value, if not provided the
	// check is for the non-existence of the
	// column in question
	//  - Tput: the TPut to put if the check succeeds
	CheckAndPut(context.Context, []byte, []byte, []byte, []byte, []byte, *hbase.TPut) (bool, error)

	// Commit a List of Puts to the table.
	//
	// Parameters:
	//  - Table: the table to put data in
	//  - Tputs: a list of TPuts to commit
	PutMultiple(context.Context, []byte, []*hbase.TPut) error

	// Deletes as specified by the TDelete.
	//
	// Note: "delete" is a reserved keyword and cannot be used in Thrift
	// thus the inconsistent naming scheme from the other functions.
	//
	// Parameters:
	//  - Table: the table to delete from
	//  - Tdelete: the TDelete to delete
	DeleteSingle(context.Context, []byte, *hbase.TDelete) error

	// Bulk commit a List of TDeletes to the table.
	//
	// Throws a TIOError if any of the deletes fail.
	//
	// Always returns an empty list for backwards compatibility.
	//
	// Parameters:
	//  - Table: the table to delete from
	//  - Tdeletes: list of TDeletes to delete
	DeleteMultiple(context.Context, []byte, []*hbase.TDelete) ([]*hbase.TDelete, error)

	// Atomically checks if a row/family/qualifier value matches the expected
	// value. If it does, it adds the delete.
	//
	// @return true if the new delete was executed, false otherwise
	//
	// Parameters:
	//  - Table: to check in and delete from
	//  - Row: row to check
	//  - Family: column family to check
	//  - Qualifier: column qualifier to check
	//  - Value: the expected value, if not provided the
	// check is for the non-existence of the
	// column in question
	//  - Tdelete: the TDelete to execute if the check succeeds
	CheckAndDelete(context.Context, []byte, []byte, []byte, []byte, []byte, *hbase.TDelete) (bool, error)

	// Parameters:
	//  - Table: the table to increment the value on
	//  - Tincrement: the TIncrement to increment
	Increment(context.Context, []byte, *hbase.TIncrement) (*hbase.TResult_, error)

	// Parameters:
	//  - Table: the table to append the value on
	//  - Tappend: the TAppend to append
	Append(context.Context, []byte, *hbase.TAppend) (*hbase.TResult_, error)

	// Get a Scanner for the provided TScan object.
	//
	// @return Scanner Id to be used with other scanner procedures
	//
	// Parameters:
	//  - Table: the table to get the Scanner for
	//  - Tscan: the scan object to get a Scanner for
	OpenScanner(context.Context, []byte, *hbase.TScan) (int32, error)

	// Grabs multiple rows from a Scanner.
	//
	// @return Between zero and numRows TResults
	//
	// Parameters:
	//  - ScannerId: the Id of the Scanner to return rows from. This is an Id returned from the openScanner function.
	//  - NumRows: number of rows to return
	GetScannerRows(context.Context, int32, int32) ([]*hbase.TResult_, error)
	// Closes the scanner. Should be called to free server side resources timely.
	// Typically close once the scanner is not needed anymore, i.e. after looping
	// over it to get all the required rows.
	//
	// Parameters:
	//  - ScannerId: the Id of the Scanner to close *
	CloseScanner(context.Context, int32) error

	// mutateRow performs multiple mutations atomically on a single row.
	//
	// Parameters:
	//  - Table: table to apply the mutations
	//  - TrowMutations: mutations to apply
	MutateRow(context.Context, []byte, *hbase.TRowMutations) error

	GetScannerResults(context.Context, []byte, *hbase.TScan, int32) ([]*hbase.TResult_, error)

	// Given a table and a row get the location of the region that
	// would contain the given row key.
	//
	// reload = true means the cache will be cleared and the location
	// will be fetched from meta.
	//
	// Parameters:
	//  - Table
	//  - Row
	//  - Reload
	GetRegionLocation(context.Context, []byte, []byte, bool) (*hbase.THRegionLocation, error)

	// Get all of the region locations for a given table.
	//
	//
	// Parameters:
	//  - Table
	GetAllRegionLocations(context.Context, []byte) ([]*hbase.THRegionLocation, error)

	// Atomically checks if a row/family/qualifier value matches the expected
	// value. If it does, it mutates the row.
	//
	// @return true if the row was mutated, false otherwise
	//
	// Parameters:
	//  - Table: to check in and delete from
	//  - Row: row to check
	//  - Family: column family to check
	//  - Qualifier: column qualifier to check
	//  - CompareOp: comparison to make on the value
	//  - Value: the expected value to be compared against, if not provided the
	// check is for the non-existence of the column in question
	//  - RowMutations: row mutations to execute if the value matches
	CheckAndMutate(context.Context, []byte, []byte, []byte, []byte, hbase.TCompareOp, []byte, *hbase.TRowMutations) (bool, error)

	// Get a table descriptor.
	// @return the TableDescriptor of the giving tablename
	//
	//
	// Parameters:
	//  - Table: the tablename of the table to get tableDescriptor
	GetTableDescriptor(context.Context, *hbase.TTableName) (*hbase.TTableDescriptor, error)

	// Get table descriptors of tables.
	// @return the TableDescriptor of the giving tablename
	//
	//
	// Parameters:
	//  - Tables: the tablename list of the tables to get tableDescriptor
	GetTableDescriptors(context.Context, []*hbase.TTableName) ([]*hbase.TTableDescriptor, error)

	//
	// @return true if table exists already, false if not
	//
	//
	// Parameters:
	//  - TableName: the tablename of the tables to check
	TableExists(context.Context, *hbase.TTableName) (bool, error)

	// Get table descriptors of tables that match the given pattern
	// @return the tableDescriptors of the matching table
	//
	//
	// Parameters:
	//  - Regex: The regular expression to match against
	//  - IncludeSysTables: set to false if match only against userspace tables
	GetTableDescriptorsByPattern(context.Context, string, bool) ([]*hbase.TTableDescriptor, error)

	// Get table descriptors of tables in the given namespace
	// @return the tableDescriptors in the namespce
	//
	//
	// Parameters:
	//  - Name: The namesapce's name
	GetTableDescriptorsByNamespace(context.Context, string) ([]*hbase.TTableDescriptor, error)

	// Get table names of tables that match the given pattern
	// @return the table names of the matching table
	//
	//
	// Parameters:
	//  - Regex: The regular expression to match against
	//  - IncludeSysTables: set to false if match only against userspace tables
	GetTableNamesByPattern(context.Context, string, bool) ([]*hbase.TTableName, error)

	// Get table names of tables in the given namespace
	// @return the table names of the matching table
	//
	//
	// Parameters:
	//  - Name: The namesapce's name
	GetTableNamesByNamespace(context.Context, string) ([]*hbase.TTableName, error)
	// Creates a new table with an initial set of empty regions defined by the specified split keys.
	// The total number of regions created will be the number of split keys plus one. Synchronous
	// operation.
	//
	//
	// Parameters:
	//  - Desc: table descriptor for table
	//  - SplitKeys: rray of split keys for the initial regions of the table
	CreateTable(context.Context, *hbase.TTableDescriptor, [][]byte) error

	// Deletes a table. Synchronous operation.
	//
	//
	// Parameters:
	//  - TableName: the tablename to delete
	DeleteTable(context.Context, *hbase.TTableName) error

	// Truncate a table. Synchronous operation.
	//
	//
	// Parameters:
	//  - TableName: the tablename to truncate
	//  - PreserveSplits: whether to  preserve previous splits
	TruncateTable(context.Context, *hbase.TTableName, bool) error

	// Enalbe a table
	//
	//
	// Parameters:
	//  - TableName: the tablename to enable
	EnableTable(context.Context, *hbase.TTableName) error

	// Disable a table
	//
	//
	// Parameters:
	//  - TableName: the tablename to disable
	DisableTable(context.Context, *hbase.TTableName) error

	//
	// @return true if table is enabled, false if not
	//
	//
	// Parameters:
	//  - TableName: the tablename to check
	IsTableEnabled(context.Context, *hbase.TTableName) (bool, error)
	//
	// @return true if table is disabled, false if not
	//
	//
	// Parameters:
	//  - TableName: the tablename to check
	IsTableDisabled(context.Context, *hbase.TTableName) (bool, error)

	//
	// @return true if table is available, false if not
	//
	//
	// Parameters:
	//  - TableName: the tablename to check
	IsTableAvailable(context.Context, *hbase.TTableName) (bool, error)

	//  * Use this api to check if the table has been created with the specified number of splitkeys
	//  * which was used while creating the given table. Note : If this api is used after a table's
	//  * region gets splitted, the api may return false.
	//  *
	//  * @return true if table is available, false if not
	// *
	//
	// Parameters:
	//  - TableName: the tablename to check
	//  - SplitKeys: keys to check if the table has been created with all split keys
	IsTableAvailableWithSplit(context.Context, *hbase.TTableName, [][]byte) (bool, error)

	// Add a column family to an existing table. Synchronous operation.
	//
	//
	// Parameters:
	//  - TableName: the tablename to add column family to
	//  - Column: column family descriptor of column family to be added
	AddColumnFamily(context.Context, *hbase.TTableName, *hbase.TColumnFamilyDescriptor) error

	// Delete a column family from a table. Synchronous operation.
	//
	//
	// Parameters:
	//  - TableName: the tablename to delete column family from
	//  - Column: name of column family to be deleted
	DeleteColumnFamily(context.Context, *hbase.TTableName, []byte) error

	// Modify an existing column family on a table. Synchronous operation.
	//
	//
	// Parameters:
	//  - TableName: the tablename to modify column family
	//  - Column: column family descriptor of column family to be modified
	ModifyColumnFamily(context.Context, *hbase.TTableName, *hbase.TColumnFamilyDescriptor) error

	// Modify an existing table
	//
	//
	// Parameters:
	//  - Desc: the descriptor of the table to modify
	ModifyTable(context.Context, *hbase.TTableDescriptor) error

	// Create a new namespace. Blocks until namespace has been successfully created or an exception is
	// thrown
	//
	//
	// Parameters:
	//  - NamespaceDesc: descriptor which describes the new namespace
	CreateNamespace(context.Context, *hbase.TNamespaceDescriptor) error

	// Modify an existing namespace.  Blocks until namespace has been successfully modified or an
	// exception is thrown
	//
	//
	// Parameters:
	//  - NamespaceDesc: descriptor which describes the new namespace
	ModifyNamespace(context.Context, *hbase.TNamespaceDescriptor) error

	// Delete an existing namespace. Only empty namespaces (no tables) can be removed.
	// Blocks until namespace has been successfully deleted or an
	// exception is thrown.
	//
	//
	// Parameters:
	//  - Name: namespace name
	DeleteNamespace(context.Context, string) error

	// Get a namespace descriptor by name.
	// @retrun the descriptor
	//
	//
	// Parameters:
	//  - Name: name of namespace descriptor
	GetNamespaceDescriptor(context.Context, string) (*hbase.TNamespaceDescriptor, error)

	// @return all namespaces
	//
	ListNamespaceDescriptors(context.Context) ([]*hbase.TNamespaceDescriptor, error)

	//Close 关闭客户端,默认如果设置请求超时则等待一个请求超时的时间,否则等待1s
	Close() error
	//Open 开启客户端
	Open() error
	//IsOpen 判断客户端是否已经开启
	IsOpen() bool

	//NewCtx 用于构造请求用的上下文
	NewCtx() (context.Context, context.CancelFunc)
}

Directories

Path Synopsis
gen-go
代理的异常定义
代理的异常定义

Jump to

Keyboard shortcuts

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