Documentation
¶
Overview ¶
客户端定义
hbase连接定义
常量定义
异常定义
初始化配置项
连接池定义
接口定义
Index ¶
- Constants
- Variables
- type Client
- func (p *Client) AddColumnFamily(ctx context.Context, tableName *hbase.TTableName, ...) error
- func (p *Client) Append(ctx context.Context, table []byte, tappend *hbase.TAppend) (*hbase.TResult_, error)
- func (p *Client) CheckAndDelete(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, ...) (bool, error)
- func (p *Client) CheckAndMutate(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, ...) (bool, error)
- func (p *Client) CheckAndPut(ctx context.Context, table []byte, row []byte, family []byte, qualifier []byte, ...) (bool, error)
- func (c *Client) Close() error
- func (p *Client) CloseScanner(ctx context.Context, scannerId int32) error
- func (p *Client) CreateNamespace(ctx context.Context, namespaceDesc *hbase.TNamespaceDescriptor) error
- func (p *Client) CreateTable(ctx context.Context, desc *hbase.TTableDescriptor, splitKeys [][]byte) error
- func (p *Client) DeleteColumnFamily(ctx context.Context, tableName *hbase.TTableName, column []byte) error
- func (p *Client) DeleteMultiple(ctx context.Context, table []byte, tdeletes []*hbase.TDelete) ([]*hbase.TDelete, error)
- func (p *Client) DeleteNamespace(ctx context.Context, name string) error
- func (p *Client) DeleteSingle(ctx context.Context, table []byte, tdelete *hbase.TDelete) error
- func (p *Client) DeleteTable(ctx context.Context, tableName *hbase.TTableName) error
- func (p *Client) DisableTable(ctx context.Context, tableName *hbase.TTableName) error
- func (p *Client) EnableTable(ctx context.Context, tableName *hbase.TTableName) error
- func (p *Client) Exists(ctx context.Context, table []byte, tget *hbase.TGet) (bool, error)
- func (p *Client) ExistsAll(ctx context.Context, table []byte, tgets []*hbase.TGet) ([]bool, error)
- func (p *Client) Get(ctx context.Context, table []byte, tget *hbase.TGet) (*hbase.TResult_, error)
- func (p *Client) GetAllRegionLocations(ctx context.Context, table []byte) ([]*hbase.THRegionLocation, error)
- func (p *Client) GetMultiple(ctx context.Context, table []byte, tgets []*hbase.TGet) ([]*hbase.TResult_, error)
- func (p *Client) GetNamespaceDescriptor(ctx context.Context, name string) (*hbase.TNamespaceDescriptor, error)
- func (p *Client) GetRegionLocation(ctx context.Context, table []byte, row []byte, reload bool) (*hbase.THRegionLocation, error)
- func (p *Client) GetScannerResults(ctx context.Context, table []byte, tscan *hbase.TScan, numRows int32) ([]*hbase.TResult_, error)
- func (p *Client) GetScannerRows(ctx context.Context, scannerId int32, numRows int32) ([]*hbase.TResult_, error)
- func (p *Client) GetTableDescriptor(ctx context.Context, table *hbase.TTableName) (*hbase.TTableDescriptor, error)
- func (p *Client) GetTableDescriptors(ctx context.Context, tables []*hbase.TTableName) ([]*hbase.TTableDescriptor, error)
- func (p *Client) GetTableDescriptorsByNamespace(ctx context.Context, name string) ([]*hbase.TTableDescriptor, error)
- func (p *Client) GetTableDescriptorsByPattern(ctx context.Context, regex string, includeSysTables bool) ([]*hbase.TTableDescriptor, error)
- func (p *Client) GetTableNamesByNamespace(ctx context.Context, name string) ([]*hbase.TTableName, error)
- func (p *Client) GetTableNamesByPattern(ctx context.Context, regex string, includeSysTables bool) ([]*hbase.TTableName, error)
- func (c *Client) HardClose() error
- func (p *Client) Increment(ctx context.Context, table []byte, tincrement *hbase.TIncrement) (*hbase.TResult_, error)
- func (c *Client) IsOpen() bool
- func (p *Client) IsTableAvailable(ctx context.Context, tableName *hbase.TTableName) (bool, error)
- func (p *Client) IsTableAvailableWithSplit(ctx context.Context, tableName *hbase.TTableName, splitKeys [][]byte) (bool, error)
- func (p *Client) IsTableDisabled(ctx context.Context, tableName *hbase.TTableName) (bool, error)
- func (p *Client) IsTableEnabled(ctx context.Context, tableName *hbase.TTableName) (bool, error)
- func (p *Client) ListNamespaceDescriptors(ctx context.Context) ([]*hbase.TNamespaceDescriptor, error)
- func (p *Client) ModifyColumnFamily(ctx context.Context, tableName *hbase.TTableName, ...) error
- func (p *Client) ModifyNamespace(ctx context.Context, namespaceDesc *hbase.TNamespaceDescriptor) error
- func (p *Client) ModifyTable(ctx context.Context, desc *hbase.TTableDescriptor) error
- func (p *Client) MutateRow(ctx context.Context, table []byte, trowMutations *hbase.TRowMutations) error
- func (c *Client) NewCtx() (ctx context.Context, cancel context.CancelFunc)
- func (c *Client) Open() error
- func (p *Client) OpenScanner(ctx context.Context, table []byte, tscan *hbase.TScan) (int32, error)
- func (p *Client) Put(ctx context.Context, table []byte, tput *hbase.TPut) error
- func (p *Client) PutMultiple(ctx context.Context, table []byte, tputs []*hbase.TPut) error
- func (c *Client) SoftClose(timeout time.Duration) error
- func (p *Client) TableExists(ctx context.Context, tableName *hbase.TTableName) (bool, error)
- func (p *Client) TruncateTable(ctx context.Context, tableName *hbase.TTableName, preserveSplits bool) error
- type Conn
- type Option
- func WithConnTimeoutS(ConnTimeoutS int) Option
- func WithIdleTimeoutS(IdleTimeoutS int) Option
- func WithIntervalMS(IntervalMS int) Option
- func WithLogger(logger logrus.FieldLogger) Option
- func WithMaxConns(MaxConns int32) Option
- func WithOptions(opts *Options) Option
- func WithParallelCallback() Option
- func WithQueryTimeoutMS(QueryTimeout int) Option
- func WithTimeoutS(TimeoutS int) Option
- func WithURL(URL string) Option
- type Options
- type PoolStatus
- type ThriftPool
- func (p *ThriftPool) CheckTimeout()
- func (p *ThriftPool) ClearConn()
- func (p *ThriftPool) CloseConn(client *Conn)
- func (p *ThriftPool) Get() (*Conn, error)
- func (p *ThriftPool) GetConnCount() int32
- func (p *ThriftPool) GetIdleCount() uint32
- func (p *ThriftPool) IsOpen() bool
- func (p *ThriftPool) Put(client *Conn) error
- func (p *ThriftPool) Reconnect(client *Conn) (newClient *Conn, err error)
- func (p *ThriftPool) Recover()
- func (p *ThriftPool) Release()
- type ThriftPoolConfig
- type UniversalClient
Constants ¶
const ( DEFAULT_CHECKINTERVAL = 120 //清除超时连接间隔 MaxInitConnCount = 10 DEFAULT_POOL_CLOSE_TIMEOUT = time.Duration(1) * time.Second )
Variables ¶
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
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 (*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) CloseScanner ¶
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 ¶
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 ¶
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 ¶
Deletes a table. Synchronous operation.
Parameters:
- TableName: the tablename to delete
func (*Client) Exists ¶
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 ¶
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 ¶
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) 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) IsTableAvailable ¶
@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 ¶
@return true if table is disabled, false if not
Parameters:
- TableName: the tablename to check
func (*Client) IsTableEnabled ¶
@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 ¶
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) OpenScanner ¶
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 ¶
Commit a TPut to a table.
Parameters:
- Table: the table to put data in
- Tput: the TPut to put
func (*Client) PutMultiple ¶
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) TableExists ¶
@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 }
type Option ¶
type Option interface {
Apply(*Options)
}
Option configures how we set up the connection.
func WithConnTimeoutS ¶
WithConnTimeoutS 创建连接超时时间,单位s
func WithIdleTimeoutS ¶
WithIdleTimeoutS 空闲客户端超时时间,超时主动释放连接,关闭客户端,单位s
func WithIntervalMS ¶
WithIntervalMS 获取Thrift客户端失败重试间隔,单位ms
func WithParallelCallback ¶
func WithParallelCallback() Option
WithParallelCallback 只对proxy有效,设置初始化后回调并行执行而非串行执行
func WithQueryTimeoutMS ¶
WithQueryTimeoutMS 设置最大请求超时,单位ms
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) GetIdleCount ¶
func (p *ThriftPool) GetIdleCount() uint32
GetIdleCount 获取现在闲置连接个数
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) }