Permalink
Browse files

improve scan support

adds support for specifying:

  - start_row
  - stop_row
  - columns
  - timestamp
  • Loading branch information...
mjrusso committed Dec 11, 2010
1 parent d55ef8a commit e729423123953246a758ee22ae1a06e8fb50382d
Showing with 25 additions and 5 deletions.
  1. +1 −1 examples/pyhbase-cli
  2. +24 −4 pyhbase/connection.py
View
@@ -165,7 +165,7 @@ if __name__=="__main__":
if len(args) != 2:
usage()
sys.exit(1)
- print connection.scan(*args)
+ pprint.pprint(connection.scan(args[0], args[1]))
elif cmd == 'delete':
if len(args) < 2:
usage()
View
@@ -204,10 +204,30 @@ def delete(self, table, row, *columns):
# TODO(hammer): Figure out cleaner, more functional command-line
@retry_wrapper
- def scan(self, table, number_of_rows):
- params = {"table": table, "scan": {}}
+ def scan(self, table, number_of_rows, start_row=None,
+ stop_row=None, columns=[], timestamp=None):
+
+ if columns:
+ columns = [{"family": column[0], "qualifier": column[1]}
+ if len(column) > 1 else {"family": column[0]}
+ for column in map(lambda s: s.split(":"), columns)]
+
+ params = {
+ "table": table,
+ "scan": {
+ "startRow": start_row,
+ "stopRow": stop_row,
+ "columns": columns,
+ "timestamp": timestamp
+ },
+ }
+
scanner_id = self.requestor.request("scannerOpen", params)
- results = self.requestor.request("scannerGetRows", {"scannerId": scanner_id, "numberOfRows": int(number_of_rows)})
+
+ results = self.requestor.request("scannerGetRows", {
+ "scannerId": scanner_id,
+ "numberOfRows": int(number_of_rows),
+ })
+
self.requestor.request("scannerClose", {"scannerId": scanner_id})
return results
-

0 comments on commit e729423

Please sign in to comment.