Permalink
Browse files

Added alter.

  • Loading branch information...
1 parent f39cbdb commit 9ad142f928bc75833a730dabd8312ca0d4625a4c @hammer hammer committed May 30, 2010
Showing with 83 additions and 18 deletions.
  1. +8 −2 examples/pyhbase-cli
  2. +12 −0 pyhbase/connection.py
  3. +62 −15 pyhbase/schema/hbase.avpr
  4. +1 −1 setup.py
View
@@ -10,16 +10,17 @@ if __name__=="__main__":
Usage: %s [-h host[:port]] command [arg1 [arg2...]]
Commands:
+ get_hbase_version
list_tables
describe_table table
- describe_family table family
is_table_enabled table
table_exists table
- get_hbase_version
+ 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
@@ -85,6 +86,11 @@ if __name__=="__main__":
usage()
sys.exit(1)
print connection.create_table(*args)
+ elif cmd == 'alter':
+ if len(args) != 3:
+ usage()
+ sys.exit(1)
+ print connection.alter(*args)
elif cmd == 'drop':
if len(args) != 1:
usage()
View
@@ -94,6 +94,18 @@ def create_table(self, table, *families):
if families: table_descriptor["families"] = families
return self.requestor.request("createTable", {"table": table_descriptor})
+ # NB: Delete is an asynchronous operation, so don't retry
+ def alter(self, table, command, family):
+ self.disable_table(table)
+ if command == "add":
+ self.requestor.request("addFamily", {"table": table, "family": {"name": family}})
+ elif command == "delete":
+ self.requestor.request("deleteFamily", {"table": table, "family": family})
+ else:
+ return "Unknown alter command: %s" % command
+ self.flush(".META.")
+ return self.enable_table(table)
+
# TODO(hammer): Automatically major_compact .META. too?
# NB: flush is an asynchronous operation, so don't retry
def drop(self, table):
View
@@ -248,44 +248,75 @@
"response" : "null",
"errors" : [ "AIOError" ]
},
- "enableTable" : {
+ "modifyTable" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "tableDescriptor",
+ "type" : "ATableDescriptor"
} ],
"response" : "null",
"errors" : [ "AIOError" ]
},
- "disableTable" : {
+ "addFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "family",
+ "type" : "AFamilyDescriptor"
} ],
"response" : "null",
"errors" : [ "AIOError" ]
},
- "flush" : {
+ "deleteFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "family",
+ "type" : "bytes"
} ],
"response" : "null",
"errors" : [ "AIOError" ]
},
- "isTableEnabled" : {
+ "modifyFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "familyName",
+ "type" : "bytes"
+ }, {
+ "name" : "familyDescriptor",
+ "type" : "AFamilyDescriptor"
} ],
- "response" : "boolean",
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "tableExists" : {
+ "enableTable" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
} ],
- "response" : "boolean",
+ "response" : "null",
+ "errors" : [ "AIOError" ]
+ },
+ "disableTable" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ } ],
+ "response" : "null",
+ "errors" : [ "AIOError" ]
+ },
+ "flush" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ } ],
+ "response" : "null",
"errors" : [ "AIOError" ]
},
"getHBaseVersion" : {
@@ -301,6 +332,22 @@
},
"errors" : [ "AIOError" ]
},
+ "isTableEnabled" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ } ],
+ "response" : "boolean",
+ "errors" : [ "AIOError" ]
+ },
+ "tableExists" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ } ],
+ "response" : "boolean",
+ "errors" : [ "AIOError" ]
+ },
"describeTable" : {
"request" : [ {
"name" : "table",
@@ -320,26 +367,26 @@
"response" : "AFamilyDescriptor",
"errors" : [ "AIOError" ]
},
- "get" : {
+ "put" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
}, {
- "name" : "get",
- "type" : "AGet"
+ "name" : "put",
+ "type" : "APut"
} ],
- "response" : "AResult",
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "put" : {
+ "get" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
}, {
- "name" : "put",
- "type" : "APut"
+ "name" : "get",
+ "type" : "AGet"
} ],
- "response" : "null",
+ "response" : "AResult",
"errors" : [ "AIOError" ]
},
"scannerOpen" : {
View
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name="PyHBase",
- version='0.0.10',
+ version='0.0.11',
description="High-level Python interface to HBase",
url="http://github.com/hammer/pyhbase/",
packages=['pyhbase'],

0 comments on commit 9ad142f

Please sign in to comment.