# Thrift module: Hbase

Module | Services | Data types | Constants
--- | --- | --- | ---
Hbase | Hbase atomicIncrement compact createTable deleteAll deleteAllRow deleteAllRowTs deleteAllTs deleteTable disableTable enableTable get getColumnDescriptors getRow getRowTs getRowWithColumns getRowWithColumnsTs getTableNames getTableRegions getVer getVerTs isTableEnabled majorCompact mutateRow mutateRowTs mutateRows mutateRowsTs scannerClose scannerGet scannerGetList scannerOpen scannerOpenTs scannerOpenWithPrefix scannerOpenWithStop scannerOpenWithStopTs | AlreadyExists BatchMutation Bytes ColumnDescriptor IOError IllegalArgument Mutation ScannerID TCell TRegionInfo TRowResult Text | ``

## Type declarations

### Typedef: Text

Base type: `string`

### Typedef: Bytes

Base type: `string`

### Typedef: ScannerID

Base type: `i32`

## Data structures

### Struct: TCell

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
value | `Bytes` |  | yes |
timestamp | `i64` |  | yes |

TCell - Used to transport a cell value (byte[]) and the timestamp it was stored with together as a result for get and getRow methods. This promotes the timestamp of a cell to a first-class value, making it easy to take note of temporal data. Cell is used all the way from HStore up to HTable.

### Struct: ColumnDescriptor

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
name | `Text` |  | yes |
maxVersions | `i32` |  | yes | 3
compression | `string` |  | yes | "NONE"
inMemory | `bool` |  | yes | 0
bloomFilterType | `string` |  | yes | "NONE"
bloomFilterVectorSize | `i32` |  | yes | 0
bloomFilterNbHashes | `i32` |  | yes | 0
blockCacheEnabled | `bool` |  | yes | 0
timeToLive | `i32` |  | yes | -1

An HColumnDescriptor contains information about a column family such as the number of versions, compression settings, etc. It is used as input when creating a table or adding a column.

### Struct: TRegionInfo

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
startKey | `Text` |  | yes |
endKey | `Text` |  | yes |
id | `i64` |  | yes |
name | `Text` |  | yes |
version | `byte` |  | yes |

A TRegionInfo contains information about an HTable region.

### Struct: Mutation

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
isDelete | `bool` |  | yes | 0
column | `Text` |  | yes |
value | `Text` |  | yes |

A Mutation object is used to either update or delete a column-value.

### Struct: BatchMutation

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
row | `Text` |  | yes |
mutations | `list<`Mutation`>` |  | yes |

A BatchMutation object is used to apply a number of Mutations to a single row.

### Struct: TRowResult

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
row | `Text` |  | yes |
columns | `map<`Text`, `TCell`>` |  | yes |

Holds row name and then a map of columns to cells.

### Exception: IOError

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
message | `string` |  | yes |

An IOError exception signals that an error occurred communicating to the Hbase master or an Hbase region server. Also used to return more general Hbase error conditions.

### Exception: IllegalArgument

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
message | `string` |  | yes |

An IllegalArgument exception indicates an illegal or invalid argument was passed into a procedure.

### Exception: AlreadyExists

Field | Type | Description | Required | Default value
--- | --- | --- | --- | ---
message | `string` |  | yes |

An AlreadyExists exceptions signals that a table with the specified name already exists

## Services

### Service: Hbase

#### Function: Hbase.enableTable

    void enableTable(Bytes tableName)
        throws IOError

Brings a table on-line (enables it)
Parameters

Name | Description
--- | ---
tableName | name of the table

#### Function: Hbase.disableTable

    void disableTable(Bytes tableName)
        throws IOError

Disables a table (takes it off-line) If it is being served, the master will tell the servers to stop serving it.
Parameters

Name | Description
--- | ---
tableName | name of the table

#### Function: Hbase.isTableEnabled

    bool isTableEnabled(Bytes tableName)
        throws IOError

@return true if table is on-line
Parameters

Name | Description
--- | ---
tableName | name of the table to check

#### Function: Hbase.compact

    void compact(Bytes tableNameOrRegionName)
        throws IOError

Parameters

Name | Description
--- | ---
tableNameOrRegionName |

#### Function: Hbase.majorCompact

    void majorCompact(Bytes tableNameOrRegionName)
        throws IOError

Parameters

Name | Description
--- | ---
tableNameOrRegionName |

#### Function: Hbase.getTableNames

    list<Text> getTableNames()
        throws IOError

List all the userspace tables.

@return returns a list of names

#### Function: Hbase.getColumnDescriptors

    map<Text, ColumnDescriptor> getColumnDescriptors(Text tableName)
        throws IOError

List all the column families assoicated with a table.

@return list of column family descriptors
Parameters

Name | Description
--- | ---
tableName | table name

#### Function: Hbase.getTableRegions

    list<TRegionInfo> getTableRegions(Text tableName)
        throws IOError

List the regions associated with a table.

@return list of region descriptors
Parameters

Name | Description
--- | ---
tableName | table name

#### Function: Hbase.createTable

    void createTable(Text tableName,
                     list<ColumnDescriptor> columnFamilies)
        throws IOError, IllegalArgument, AlreadyExists

Create a table with the specified column families. The name field for each ColumnDescriptor must be set and must end in a colon (:). All other fields are optional and will get default values if not explicitly specified.

@throws IllegalArgument if an input parameter is invalid

@throws AlreadyExists if the table name already exists
Parameters

Name | Description
--- | ---
tableName | name of table to create
columnFamilies | list of column family descriptors

#### Function: Hbase.deleteTable

    void deleteTable(Text tableName)
        throws IOError

Deletes a table

@throws IOError if table doesn't exist on server or there was some other problem
Parameters

Name | Description
--- | ---
tableName | name of table to delete

#### Function: Hbase.get

    list<TCell> get(Text tableName,
                    Text row,
                    Text column)
        throws IOError

Get a single TCell for the specified table, row, and column at the latest timestamp. Returns an empty list if no such value exists.

@return value for specified row/column
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
column | column name

#### Function: Hbase.getVer

    list<TCell> getVer(Text tableName,
                       Text row,
                       Text column,
                       i32 numVersions)
        throws IOError

Get the specified number of versions for the specified table, row, and column.

@return list of cells for specified row/column
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
column | column name
numVersions | number of versions to retrieve

#### Function: Hbase.getVerTs

    list<TCell> getVerTs(Text tableName,
                         Text row,
                         Text column,
                         i64 timestamp,
                         i32 numVersions)
        throws IOError

Get the specified number of versions for the specified table, row, and column. Only versions less than or equal to the specified timestamp will be returned.

@return list of cells for specified row/column
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
column | column name
timestamp | timestamp
numVersions | number of versions to retrieve

#### Function: Hbase.getRow

    list<TRowResult> getRow(Text tableName,
                            Text row)
        throws IOError

Get all the data for the specified table and row at the latest timestamp. Returns an empty list if the row does not exist.

@return TRowResult containing the row and map of columns to TCells
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key

#### Function: Hbase.getRowWithColumns

    list<TRowResult> getRowWithColumns(Text tableName,
                                       Text row,
                                       list<Text> columns)
        throws IOError

Get the specified columns for the specified table and row at the latest timestamp. Returns an empty list if the row does not exist.

@return TRowResult containing the row and map of columns to TCells
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
columns | List of columns to return, null for all columns

#### Function: Hbase.getRowTs

    list<TRowResult> getRowTs(Text tableName,
                              Text row,
                              i64 timestamp)
        throws IOError

Get all the data for the specified table and row at the specified timestamp. Returns an empty list if the row does not exist.

@return TRowResult containing the row and map of columns to TCells
Parameters

Name | Description
--- | ---
tableName | name of the table
row | row key
timestamp | timestamp

#### Function: Hbase.getRowWithColumnsTs

    list<TRowResult> getRowWithColumnsTs(Text tableName,
                                         Text row,
                                         list<Text> columns,
                                         i64 timestamp)
        throws IOError

Get the specified columns for the specified table and row at the specified timestamp. Returns an empty list if the row does not exist.

@return TRowResult containing the row and map of columns to TCells
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
columns | List of columns to return, null for all columns
timestamp |

#### Function: Hbase.mutateRow

    void mutateRow(Text tableName,
                   Text row,
                   list<Mutation> mutations)
        throws IOError, IllegalArgument

Apply a series of mutations (updates/deletes) to a row in a single transaction. If an exception is thrown, then the transaction is aborted. Default current timestamp is used, and all entries will have an identical timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
mutations | list of mutation commands

#### Function: Hbase.mutateRowTs

    void mutateRowTs(Text tableName,
                     Text row,
                     list<Mutation> mutations,
                     i64 timestamp)
        throws IOError, IllegalArgument

Apply a series of mutations (updates/deletes) to a row in a single transaction. If an exception is thrown, then the transaction is aborted. The specified timestamp is used, and all entries will have an identical timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
row | row key
mutations | list of mutation commands
timestamp | timestamp

#### Function: Hbase.mutateRows

    void mutateRows(Text tableName,
                    list<BatchMutation> rowBatches)
        throws IOError, IllegalArgument

Apply a series of batches (each a series of mutations on a single row) in a single transaction. If an exception is thrown, then the transaction is aborted. Default current timestamp is used, and all entries will have an identical timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
rowBatches | list of row batches

#### Function: Hbase.mutateRowsTs

    void mutateRowsTs(Text tableName,
                      list<BatchMutation> rowBatches,
                      i64 timestamp)
        throws IOError, IllegalArgument

Apply a series of batches (each a series of mutations on a single row) in a single transaction. If an exception is thrown, then the transaction is aborted. The specified timestamp is used, and all entries will have an identical timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
rowBatches | list of row batches
timestamp | timestamp

#### Function: Hbase.atomicIncrement

    i64 atomicIncrement(Text tableName,
                        Text row,
                        Text column,
                        i64 value)
        throws IOError, IllegalArgument

Atomically increment the column value specified. Returns the next value post increment.
Parameters

Name | Description
--- | ---
tableName | name of table
row | row to increment
column | name of column
value | amount to increment by

#### Function: Hbase.deleteAll

    void deleteAll(Text tableName,
                   Text row,
                   Text column)
        throws IOError

Delete all cells that match the passed row and column.
Parameters

Name | Description
--- | ---
tableName | name of table
row | Row to update
column | name of column whose value is to be deleted

#### Function: Hbase.deleteAllTs

    void deleteAllTs(Text tableName,
                     Text row,
                     Text column,
                     i64 timestamp)
        throws IOError

Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
row | Row to update
column | name of column whose value is to be deleted
timestamp | timestamp

#### Function: Hbase.deleteAllRow

    void deleteAllRow(Text tableName,
                      Text row)
        throws IOError

Completely delete the row's cells.
Parameters

Name | Description
--- | ---
tableName | name of table
row | key of the row to be completely deleted.

#### Function: Hbase.deleteAllRowTs

    void deleteAllRowTs(Text tableName,
                        Text row,
                        i64 timestamp)
        throws IOError

Completely delete the row's cells marked with a timestamp equal-to or older than the passed timestamp.
Parameters

Name | Description
--- | ---
tableName | name of table
row | key of the row to be completely deleted.
timestamp | timestamp

#### Function: Hbase.scannerOpen

    ScannerID scannerOpen(Text tableName,
                          Text startRow,
                          list<Text> columns)
        throws IOError

Get a scanner on the current table starting at the specified row and ending at the last row in the table. Return the specified columns.

@return scanner id to be used with other scanner procedures
Parameters

Name | Description
--- | ---
tableName | name of table
startRow | Starting row in table to scan. Send "" (empty string) to start at the first row.
columns | columns to scan. If column name is a column family, all columns of the specified column family are returned. It's also possible to pass a regex in the column qualifier.

#### Function: Hbase.scannerOpenWithStop

    ScannerID scannerOpenWithStop(Text tableName,
                                  Text startRow,
                                  Text stopRow,
                                  list<Text> columns)
        throws IOError

Get a scanner on the current table starting and stopping at the specified rows. ending at the last row in the table. Return the specified columns.

@return scanner id to be used with other scanner procedures
Parameters

Name | Description
--- | ---
tableName | name of table
startRow | Starting row in table to scan. Send "" (empty string) to start at the first row.
stopRow | row to stop scanning on. This row is *not* included in the scanner's results
columns | columns to scan. If column name is a column family, all columns of the specified column family are returned. It's also possible to pass a regex in the column qualifier.

#### Function: Hbase.scannerOpenWithPrefix

    ScannerID scannerOpenWithPrefix(Text tableName,
                                    Text startAndPrefix,
                                    list<Text> columns)
        throws IOError

Open a scanner for a given prefix. That is all rows will have the specified prefix. No other rows will be returned.

@return scanner id to use with other scanner calls
Parameters

Name | Description
--- | ---
tableName | name of table
startAndPrefix | the prefix (and thus start row) of the keys you want
columns | the columns you want returned

#### Function: Hbase.scannerOpenTs

    ScannerID scannerOpenTs(Text tableName,
                            Text startRow,
                            list<Text> columns,
                            i64 timestamp)
        throws IOError

Get a scanner on the current table starting at the specified row and ending at the last row in the table. Return the specified columns. Only values with the specified timestamp are returned.

@return scanner id to be used with other scanner procedures
Parameters

Name | Description
--- | ---
tableName | name of table
startRow | Starting row in table to scan. Send "" (empty string) to start at the first row.
columns | columns to scan. If column name is a column family, all columns of the specified column family are returned. It's also possible to pass a regex in the column qualifier.
timestamp | timestamp

#### Function: Hbase.scannerOpenWithStopTs

    ScannerID scannerOpenWithStopTs(Text tableName,
                                    Text startRow,
                                    Text stopRow,
                                    list<Text> columns,
                                    i64 timestamp)
        throws IOError

Get a scanner on the current table starting and stopping at the specified rows. ending at the last row in the table. Return the specified columns. Only values with the specified timestamp are returned.

@return scanner id to be used with other scanner procedures
Parameters

Name | Description
--- | ---
tableName | name of table
startRow | Starting row in table to scan. Send "" (empty string) to start at the first row.
stopRow | row to stop scanning on. This row is *not* included in the scanner's results
columns | columns to scan. If column name is a column family, all columns of the specified column family are returned. It's also possible to pass a regex in the column qualifier.
timestamp | timestamp

#### Function: Hbase.scannerGet

    list<TRowResult> scannerGet(ScannerID id)
        throws IOError, IllegalArgument

Returns the scanner's current row value and advances to the next row in the table. When there are no more rows in the table, or a key greater-than-or-equal-to the scanner's specified stopRow is reached, an empty list is returned.

@return a TRowResult containing the current row and a map of the columns to TCells.

@throws IllegalArgument if ScannerID is invalid

@throws NotFound when the scanner reaches the end
Parameters

Name | Description
--- | ---
id | id of a scanner returned by scannerOpen

#### Function: Hbase.scannerGetList

    list<TRowResult> scannerGetList(ScannerID id,
                                    i32 nbRows)
        throws IOError, IllegalArgument

Returns, starting at the scanner's current row value nbRows worth of rows and advances to the next row in the table. When there are no more rows in the table, or a key greater-than-or-equal-to the scanner's specified stopRow is reached, an empty list is returned.

@return a TRowResult containing the current row and a map of the columns to TCells.

@throws IllegalArgument if ScannerID is invalid

@throws NotFound when the scanner reaches the end
Parameters

Name | Description
--- | ---
id | id of a scanner returned by scannerOpen
nbRows | number of results to return

#### Function: Hbase.scannerClose

    void scannerClose(ScannerID id)
        throws IOError, IllegalArgument

Closes the server-state associated with an open scanner.

@throws IllegalArgument if ScannerID is invalid
Parameters

Name | Description
--- | ---
id | id of a scanner returned by scannerOpen