Permalink
Browse files

Adding split and exists, reorganizing commands, and upping version to…

… 0.1.0 since the Avro server is now in trunk.
  • Loading branch information...
1 parent 375de90 commit c853375a47695ddb736f6411153d99a5bb1b5c6d @hammer hammer committed Jun 17, 2010
Showing with 305 additions and 254 deletions.
  1. +41 −19 examples/pyhbase-cli
  2. +13 −0 pyhbase/connection.py
  3. +250 −234 pyhbase/schema/hbase.avpr
  4. +1 −1 setup.py
View
@@ -11,27 +11,39 @@ if __name__=="__main__":
Usage: %s [-h host[:port]] command [arg1 [arg2...]]
Commands:
- get_hbase_version
- get_cluster_status
- list_tables
- describe_table table
- is_table_enabled table
- table_exists table
- describe_family table family
- create_table table [family1 [family2 ...]]
- enable_table table
- disable_table table
- alter table (add|delete) family
- drop table
- truncate table
- flush table
+ Cluster metadata:
+ get_hbase_version
+ get_cluster_status
+ list_tables
- put table row family1:qualifier1 value1 [family2:qualifier2 value2 ...]
- incr table row family:qualifier [amount]
- get table row [family1[:qualifier1] [family2[:qualifier2] ...]]
- delete table row [family1[:qualifier1] [family2[:qualifier2] ...]]
- scan table number_of_rows
+ Table metadata:
+ describe_table table
+ is_table_enabled table
+ table_exists table
+
+ Family metadata:
+ describe_family table family
+
+ Table admin:
+ create_table table [family1 [family2 ...]]
+ drop table
+ truncate table
+ enable_table table
+ disable_table table
+ flush table
+ split table
+ alter table (add|delete) family
+
+ Single Row DML:
+ get table row [family1[:qualifier1] [family2[:qualifier2] ...]]
+ exists table row [family1[:qualifier1] [family2[:qualifier2] ...]]
+ put table row family1:qualifier1 value1 [family2:qualifier2 value2 ...]
+ incr table row family:qualifier [amount]
+ delete table row [family1[:qualifier1] [family2[:qualifier2] ...]]
+
+ Multi-Row DML:
+ scan table number_of_rows
""" % sys.argv[0]
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
@@ -124,11 +136,21 @@ if __name__=="__main__":
usage()
sys.exit(1)
print connection.flush(*args)
+ elif cmd == 'split':
+ if len(args) != 1:
+ usage()
+ sys.exit(1)
+ print connection.split(*args)
elif cmd == 'get':
if len(args) < 2:
usage()
sys.exit(1)
print connection.get(*args)
+ elif cmd == 'exists':
+ if len(args) < 2:
+ usage()
+ sys.exit(1)
+ print connection.exists(*args)
elif cmd == 'put':
if len(args) < 4 or not len(args) % 2 == 0:
usage()
View
@@ -126,6 +126,10 @@ def truncate(self, table):
def flush(self, table):
self.requestor.request("flush", {"table": table})
+ # NB: split is an asynchronous operation, so don't retry
+ def split(self, table):
+ self.requestor.request("split", {"table": table})
+
@retry_wrapper
def enable_table(self, table):
return self.requestor.request("enableTable", {"table": table})
@@ -149,6 +153,15 @@ def get(self, table, row, *columns):
params = {"table": table, "get": get}
return self.requestor.request("get", params)
+ @retry_wrapper
+ def exists(self, table, row, *columns):
+ get = {"row": row}
+ columns = [len(column) > 1 and {"family": column[0], "qualifier": column[1]} or {"family": column[0]}
+ for column in map(lambda s: s.split(":"), columns)]
+ if columns: get["columns"] = columns
+ params = {"table": table, "get": get}
+ return self.requestor.request("exists", params)
+
#
# Put
#
Oops, something went wrong.

0 comments on commit c853375

Please sign in to comment.