Permalink
Browse files

Added scan.

  • Loading branch information...
hammer committed May 23, 2010
1 parent b5cee62 commit c163d718c4336a15e56f390f71b32a77c4bf27ab
Showing with 74 additions and 0 deletions.
  1. +7 −0 examples/pyhbase-cli
  2. +9 −0 pyhbase/connection.py
  3. +58 −0 pyhbase/schema/hbase.avpr
View
@@ -22,6 +22,8 @@ if __name__=="__main__":
get table row [family1[:qualifier1] [family2[:qualifier2] ...]]
put table row family1:qualifier1 value1 [family2:qualifier2 value2 ...]
+
+ scan table number_of_rows
""" % sys.argv[0]
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
@@ -89,6 +91,11 @@ if __name__=="__main__":
usage()
sys.exit(1)
print connection.put(*args)
+ elif cmd == 'scan':
+ if len(args) != 2:
+ usage()
+ sys.exit(1)
+ print connection.scan(*args)
else:
usage()
sys.exit(1)
View
@@ -130,3 +130,12 @@ def put(self, table, row, *column_values):
# Scan
#
+ # TODO(hammer): Figure out cleaner, more functional command-line
+ @retry_wrapper
+ def scan(self, table, number_of_rows):
+ params = {"table": table, "scan": {}}
+ scanner_id = self.requestor.request("scannerOpen", params)
+ results = self.requestor.request("scannerGetRows", {"scannerId": scanner_id, "numberOfRows": int(number_of_rows)})
+ self.requestor.request("scannerClose", {"scannerId": scanner_id})
+ return results
+
View
@@ -164,6 +164,31 @@
"items" : "AColumnValue"
}
} ]
+ }, {
+ "type" : "record",
+ "name" : "AScan",
+ "fields" : [ {
+ "name" : "startRow",
+ "type" : [ "bytes", "null" ]
+ }, {
+ "name" : "stopRow",
+ "type" : [ "bytes", "null" ]
+ }, {
+ "name" : "columns",
+ "type" : [ {
+ "type" : "array",
+ "items" : "AColumn"
+ }, "null" ]
+ }, {
+ "name" : "timestamp",
+ "type" : [ "long", "null" ]
+ }, {
+ "name" : "timerange",
+ "type" : [ "ATimeRange", "null" ]
+ }, {
+ "name" : "maxVersions",
+ "type" : [ "int", "null" ]
+ } ]
}, {
"type" : "error",
"name" : "AIOError",
@@ -274,6 +299,39 @@
} ],
"response" : "null",
"errors" : [ "AIOError" ]
+ },
+ "scannerOpen" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ }, {
+ "name" : "scan",
+ "type" : "AScan"
+ } ],
+ "response" : "int",
+ "errors" : [ "AIOError" ]
+ },
+ "scannerClose" : {
+ "request" : [ {
+ "name" : "scannerId",
+ "type" : "int"
+ } ],
+ "response" : "null",
+ "errors" : [ "AIOError", "AIllegalArgument" ]
+ },
+ "scannerGetRows" : {
+ "request" : [ {
+ "name" : "scannerId",
+ "type" : "int"
+ }, {
+ "name" : "numberOfRows",
+ "type" : "int"
+ } ],
+ "response" : {
+ "type" : "array",
+ "items" : "AResult"
+ },
+ "errors" : [ "AIOError", "AIllegalArgument" ]
}
}
}

0 comments on commit c163d71

Please sign in to comment.