Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added scan.

  • Loading branch information...
commit c163d718c4336a15e56f390f71b32a77c4bf27ab 1 parent b5cee62
@hammer hammer authored
View
7 examples/pyhbase-cli
@@ -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
9 pyhbase/connection.py
@@ -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
58 pyhbase/schema/hbase.avpr
@@ -165,6 +165,31 @@
}
} ]
}, {
+ "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",
"fields" : [ {
@@ -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" ]
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.