Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 62 additions & 18 deletions happybase/Hbase.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ColumnDescriptor {
6:i32 bloomFilterVectorSize = 0,
7:i32 bloomFilterNbHashes = 0,
8:bool blockCacheEnabled = 0,
9:i32 timeToLive = -1
9:i32 timeToLive = 0x7fffffff
}

/**
Expand Down Expand Up @@ -150,7 +150,8 @@ struct TScan {
6:optional Text filterString,
7:optional i32 batchSize,
8:optional bool sortColumns,
9:optional bool reversed
9:optional bool reversed,
10:optional bool cacheBlocks
}

/**
Expand All @@ -173,6 +174,7 @@ struct TAppend {
*/
exception IOError {
1:string message
2:bool canRetry
}

/**
Expand All @@ -191,6 +193,30 @@ exception AlreadyExists {
1:string message
}

/**
* Specify type of thrift server: thrift and thrift2
*/
enum TThriftServerType {
ONE = 1,
TWO = 2
}

enum TPermissionScope {
TABLE = 0,
NAMESPACE = 1
}

/**
* TAccessControlEntity for permission control
*/
struct TAccessControlEntity {
1: required string username
2: required TPermissionScope scope
4: required string actions
5: optional Bytes tableName
6: optional string nsName
}

//
// Service
//
Expand Down Expand Up @@ -235,6 +261,14 @@ service Hbase {
list<Text> getTableNames()
throws (1:IOError io)

/**
* List all the userspace tables and their enabled or disabled flags.
*
* @return list of tables with is enabled flags
*/
map<Text,bool> getTableNamesWithIsTableEnabled()
throws (1:IOError io)

/**
* List all the column families assoicated with a table.
*
Expand Down Expand Up @@ -906,22 +940,6 @@ service Hbase {
1:ScannerID id
) throws (1:IOError io, 2:IllegalArgument ia)

/**
* Get the row just before the specified one.
*
* @return value for specified row/column
*/
list<TCell> getRowOrBefore(
/** name of table */
1:Text tableName,

/** row key */
2:Text row,

/** column name */
3:Text family
) throws (1:IOError io)

/**
* Get the regininfo for the specified row. It scans
* the metatable to find region's start and end keys.
Expand Down Expand Up @@ -972,4 +990,30 @@ service Hbase {
/** Mutation attributes */
7:map<Text, Text> attributes
) throws (1:IOError io, 2:IllegalArgument ia)

/**
* Get the type of this thrift server.
*
* @return the type of this thrift server
*/
TThriftServerType getThriftServerType()

/**
* Returns the cluster ID for this cluster.
*/
string getClusterId()

/**
* Grant permissions in namespace or table level.
*/
bool grant(
1: required TAccessControlEntity info
) throws (1: IOError io)

/**
* Revoke permissions in namespace or table level.
*/
bool revoke(
1: required TAccessControlEntity info
) throws (1: IOError io)
}
13 changes: 12 additions & 1 deletion happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def cells(self, row, column, versions=None, timestamp=None,
def scan(self, row_start=None, row_stop=None, row_prefix=None,
columns=None, filter=None, timestamp=None,
include_timestamp=False, batch_size=1000, scan_batching=None,
limit=None, sorted_columns=False, reverse=False):
limit=None, sorted_columns=False, reverse=False,
cache_blocks=True):
"""Create a scanner for data in the table.

This method returns an iterable that can be used for looping over the
Expand Down Expand Up @@ -273,6 +274,11 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
Note that the start of the range is inclusive, while the end is
exclusive just as in the forward scan.

The `cache_blocks` argument translates to `Scan.setCacheBlocks()`
at the Java side and defaults to `True`. Set it to `False` to avoid
filling the block cache on the region servers, e.g. for large full
table scans.

**Compatibility notes:**

* The `filter` argument is only available when using HBase 0.92
Expand All @@ -285,6 +291,9 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
* The `reverse` argument is only available when using HBase 0.98
(or up).

.. versionadded:: 1.4.0
`cache_blocks` argument

.. versionadded:: 1.1.0
`reverse` argument

Expand All @@ -306,6 +315,7 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
:param int limit: max number of rows to return
:param bool sorted_columns: whether to return sorted columns
:param bool reverse: whether to perform scan in reverse
:param bool cache_blocks: whether to use the server side block cache

:return: generator yielding the rows matching the scan
:rtype: iterable of `(row_key, row_data)` tuples
Expand Down Expand Up @@ -397,6 +407,7 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
batchSize=scan_batching,
sortColumns=sorted_columns,
reversed=reverse,
cacheBlocks=cache_blocks,
)
scan_id = self.connection.client.scannerOpenWithScan(
self.name, scan, {})
Expand Down
3 changes: 3 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ def calc_len(scanner):
scanner = table.scan(row_prefix=b'row-scan-b', batch_size=5, limit=10)
assert 10 == calc_len(scanner)

scanner = table.scan(row_prefix=b'row-scan-b', cache_blocks=False)
assert 2000 == calc_len(scanner)

scanner = table.scan(timestamp=123)
assert 0 == calc_len(scanner)

Expand Down
Loading