Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit c853375a47695ddb736f6411153d99a5bb1b5c6d 1 parent 375de90
@hammer authored
View
60 examples/pyhbase-cli
@@ -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
13 pyhbase/connection.py
@@ -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
#
View
484 pyhbase/schema/hbase.avpr
@@ -2,6 +2,131 @@
"protocol" : "HBase",
"namespace" : "org.apache.hadoop.hbase.avro.generated",
"types" : [ {
+ "type" : "record",
+ "name" : "AServerAddress",
+ "fields" : [ {
+ "name" : "hostname",
+ "type" : "string"
+ }, {
+ "name" : "inetSocketAddress",
+ "type" : "string"
+ }, {
+ "name" : "port",
+ "type" : "int"
+ } ]
+ }, {
+ "type" : "record",
+ "name" : "ARegionLoad",
+ "fields" : [ {
+ "name" : "memStoreSizeMB",
+ "type" : "int"
+ }, {
+ "name" : "name",
+ "type" : "bytes"
+ }, {
+ "name" : "storefileIndexSizeMB",
+ "type" : "int"
+ }, {
+ "name" : "storefiles",
+ "type" : "int"
+ }, {
+ "name" : "storefileSizeMB",
+ "type" : "int"
+ }, {
+ "name" : "stores",
+ "type" : "int"
+ } ]
+ }, {
+ "type" : "record",
+ "name" : "AServerLoad",
+ "fields" : [ {
+ "name" : "load",
+ "type" : "int"
+ }, {
+ "name" : "maxHeapMB",
+ "type" : "int"
+ }, {
+ "name" : "memStoreSizeInMB",
+ "type" : "int"
+ }, {
+ "name" : "numberOfRegions",
+ "type" : "int"
+ }, {
+ "name" : "numberOfRequests",
+ "type" : "int"
+ }, {
+ "name" : "regionsLoad",
+ "type" : {
+ "type" : "array",
+ "items" : "ARegionLoad"
+ }
+ }, {
+ "name" : "storefileIndexSizeInMB",
+ "type" : "int"
+ }, {
+ "name" : "storefiles",
+ "type" : "int"
+ }, {
+ "name" : "storefileSizeInMB",
+ "type" : "int"
+ }, {
+ "name" : "usedHeapMB",
+ "type" : "int"
+ } ]
+ }, {
+ "type" : "record",
+ "name" : "AServerInfo",
+ "fields" : [ {
+ "name" : "infoPort",
+ "type" : "int"
+ }, {
+ "name" : "load",
+ "type" : "AServerLoad"
+ }, {
+ "name" : "serverAddress",
+ "type" : "AServerAddress"
+ }, {
+ "name" : "serverName",
+ "type" : "string"
+ }, {
+ "name" : "startCode",
+ "type" : "long"
+ } ]
+ }, {
+ "type" : "record",
+ "name" : "AClusterStatus",
+ "fields" : [ {
+ "name" : "averageLoad",
+ "type" : "double"
+ }, {
+ "name" : "deadServerNames",
+ "type" : {
+ "type" : "array",
+ "items" : "string"
+ }
+ }, {
+ "name" : "deadServers",
+ "type" : "int"
+ }, {
+ "name" : "hbaseVersion",
+ "type" : "string"
+ }, {
+ "name" : "regionsCount",
+ "type" : "int"
+ }, {
+ "name" : "requestsCount",
+ "type" : "int"
+ }, {
+ "name" : "serverInfos",
+ "type" : {
+ "type" : "array",
+ "items" : "AServerInfo"
+ }
+ }, {
+ "name" : "servers",
+ "type" : "int"
+ } ]
+ }, {
"type" : "enum",
"name" : "ACompressionAlgorithm",
"symbols" : [ "LZO", "GZ", "NONE" ]
@@ -76,35 +201,6 @@
} ]
}, {
"type" : "record",
- "name" : "AResultEntry",
- "fields" : [ {
- "name" : "family",
- "type" : "bytes"
- }, {
- "name" : "qualifier",
- "type" : "bytes"
- }, {
- "name" : "value",
- "type" : "bytes"
- }, {
- "name" : "timestamp",
- "type" : "long"
- } ]
- }, {
- "type" : "record",
- "name" : "AResult",
- "fields" : [ {
- "name" : "row",
- "type" : "bytes"
- }, {
- "name" : "entries",
- "type" : [ {
- "type" : "array",
- "items" : "AResultEntry"
- }, "null" ]
- } ]
- }, {
- "type" : "record",
"name" : "ATimeRange",
"fields" : [ {
"name" : "minStamp",
@@ -137,7 +233,7 @@
} ]
}, {
"type" : "record",
- "name" : "AColumnValue",
+ "name" : "AResultEntry",
"fields" : [ {
"name" : "family",
"type" : "bytes"
@@ -149,186 +245,87 @@
"type" : "bytes"
}, {
"name" : "timestamp",
- "type" : [ "long", "null" ]
+ "type" : "long"
} ]
}, {
"type" : "record",
- "name" : "APut",
+ "name" : "AResult",
"fields" : [ {
"name" : "row",
"type" : "bytes"
}, {
- "name" : "columnValues",
- "type" : {
+ "name" : "entries",
+ "type" : [ {
"type" : "array",
- "items" : "AColumnValue"
- }
+ "items" : "AResultEntry"
+ }, "null" ]
} ]
}, {
"type" : "record",
- "name" : "AScan",
+ "name" : "AColumnValue",
"fields" : [ {
- "name" : "startRow",
- "type" : [ "bytes", "null" ]
+ "name" : "family",
+ "type" : "bytes"
}, {
- "name" : "stopRow",
- "type" : [ "bytes", "null" ]
+ "name" : "qualifier",
+ "type" : "bytes"
}, {
- "name" : "columns",
- "type" : [ {
- "type" : "array",
- "items" : "AColumn"
- }, "null" ]
+ "name" : "value",
+ "type" : "bytes"
}, {
"name" : "timestamp",
"type" : [ "long", "null" ]
- }, {
- "name" : "timerange",
- "type" : [ "ATimeRange", "null" ]
- }, {
- "name" : "maxVersions",
- "type" : [ "int", "null" ]
} ]
}, {
"type" : "record",
- "name" : "ADelete",
+ "name" : "APut",
"fields" : [ {
"name" : "row",
"type" : "bytes"
}, {
- "name" : "columns",
- "type" : [ {
+ "name" : "columnValues",
+ "type" : {
"type" : "array",
- "items" : "AColumn"
- }, "null" ]
- } ]
- }, {
- "type" : "record",
- "name" : "AServerAddress",
- "fields" : [ {
- "name" : "bindAddress",
- "type" : "string"
- }, {
- "name" : "hostname",
- "type" : "string"
- }, {
- "name" : "inetSocketAddress",
- "type" : "string"
- }, {
- "name" : "port",
- "type" : "int"
+ "items" : "AColumnValue"
+ }
} ]
}, {
"type" : "record",
- "name" : "ARegionLoad",
+ "name" : "ADelete",
"fields" : [ {
- "name" : "memStoreSizeMB",
- "type" : "int"
- }, {
- "name" : "name",
+ "name" : "row",
"type" : "bytes"
}, {
- "name" : "storefileIndexSizeMB",
- "type" : "int"
- }, {
- "name" : "storefiles",
- "type" : "int"
- }, {
- "name" : "storefileSizeMB",
- "type" : "int"
- }, {
- "name" : "stores",
- "type" : "int"
- } ]
- }, {
- "type" : "record",
- "name" : "AServerLoad",
- "fields" : [ {
- "name" : "load",
- "type" : "int"
- }, {
- "name" : "maxHeapMB",
- "type" : "int"
- }, {
- "name" : "memStoreSizeInMB",
- "type" : "int"
- }, {
- "name" : "numberOfRegions",
- "type" : "int"
- }, {
- "name" : "numberOfRequests",
- "type" : "int"
- }, {
- "name" : "regionsLoad",
+ "name" : "columns",
"type" : [ {
"type" : "array",
- "items" : "ARegionLoad"
+ "items" : "AColumn"
}, "null" ]
- }, {
- "name" : "storefileIndexSizeInMB",
- "type" : "int"
- }, {
- "name" : "storefiles",
- "type" : "int"
- }, {
- "name" : "storefileSizeInMB",
- "type" : "int"
- }, {
- "name" : "usedHeapMB",
- "type" : "int"
} ]
}, {
"type" : "record",
- "name" : "AServerInfo",
+ "name" : "AScan",
"fields" : [ {
- "name" : "infoPort",
- "type" : "int"
- }, {
- "name" : "load",
- "type" : "AServerLoad"
- }, {
- "name" : "serverAddress",
- "type" : "AServerAddress"
- }, {
- "name" : "serverName",
- "type" : "string"
+ "name" : "startRow",
+ "type" : [ "bytes", "null" ]
}, {
- "name" : "startCode",
- "type" : "long"
- } ]
- }, {
- "type" : "record",
- "name" : "AClusterStatus",
- "fields" : [ {
- "name" : "averageLoad",
- "type" : "double"
+ "name" : "stopRow",
+ "type" : [ "bytes", "null" ]
}, {
- "name" : "deadServerNames",
+ "name" : "columns",
"type" : [ {
"type" : "array",
- "items" : "string"
+ "items" : "AColumn"
}, "null" ]
}, {
- "name" : "deadServers",
- "type" : "int"
- }, {
- "name" : "hbaseVersion",
- "type" : "string"
- }, {
- "name" : "regionsCount",
- "type" : "int"
- }, {
- "name" : "requestsCount",
- "type" : "int"
+ "name" : "timestamp",
+ "type" : [ "long", "null" ]
}, {
- "name" : "serverInfos",
- "type" : [ {
- "type" : "array",
- "items" : "AServerInfo"
- }, "null" ]
+ "name" : "timerange",
+ "type" : [ "ATimeRange", "null" ]
}, {
- "name" : "servers",
- "type" : "int"
+ "name" : "maxVersions",
+ "type" : [ "int", "null" ]
} ]
}, {
"type" : "error",
@@ -360,65 +357,82 @@
} ]
} ],
"messages" : {
- "createTable" : {
+ "getHBaseVersion" : {
+ "request" : [ ],
+ "response" : "string",
+ "errors" : [ "AIOError" ]
+ },
+ "getClusterStatus" : {
+ "request" : [ ],
+ "response" : "AClusterStatus",
+ "errors" : [ "AIOError" ]
+ },
+ "listTables" : {
+ "request" : [ ],
+ "response" : {
+ "type" : "array",
+ "items" : "ATableDescriptor"
+ },
+ "errors" : [ "AIOError" ]
+ },
+ "describeTable" : {
"request" : [ {
"name" : "table",
- "type" : "ATableDescriptor"
+ "type" : "bytes"
} ],
- "response" : "null",
- "errors" : [ "AIOError", "AIllegalArgument", "ATableExists", "AMasterNotRunning" ]
+ "response" : "ATableDescriptor",
+ "errors" : [ "AIOError" ]
},
- "deleteTable" : {
+ "isTableEnabled" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
} ],
- "response" : "null",
+ "response" : "boolean",
"errors" : [ "AIOError" ]
},
- "modifyTable" : {
+ "tableExists" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
- }, {
- "name" : "tableDescriptor",
- "type" : "ATableDescriptor"
} ],
- "response" : "null",
+ "response" : "boolean",
"errors" : [ "AIOError" ]
},
- "addFamily" : {
+ "describeFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
}, {
"name" : "family",
- "type" : "AFamilyDescriptor"
+ "type" : "bytes"
} ],
- "response" : "null",
+ "response" : "AFamilyDescriptor",
"errors" : [ "AIOError" ]
},
- "deleteFamily" : {
+ "createTable" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "ATableDescriptor"
+ } ],
+ "response" : "null",
+ "errors" : [ "AIOError", "AIllegalArgument", "ATableExists", "AMasterNotRunning" ]
+ },
+ "deleteTable" : {
"request" : [ {
"name" : "table",
- "type" : "bytes"
- }, {
- "name" : "family",
"type" : "bytes"
} ],
"response" : "null",
"errors" : [ "AIOError" ]
},
- "modifyFamily" : {
+ "modifyTable" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
}, {
- "name" : "familyName",
- "type" : "bytes"
- }, {
- "name" : "familyDescriptor",
- "type" : "AFamilyDescriptor"
+ "name" : "tableDescriptor",
+ "type" : "ATableDescriptor"
} ],
"response" : "null",
"errors" : [ "AIOError" ]
@@ -447,57 +461,70 @@
"response" : "null",
"errors" : [ "AIOError" ]
},
- "getHBaseVersion" : {
- "request" : [ ],
- "response" : "string",
- "errors" : [ "AIOError" ]
- },
- "getClusterStatus" : {
- "request" : [ ],
- "response" : "AClusterStatus",
+ "split" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ } ],
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "listTables" : {
- "request" : [ ],
- "response" : {
- "type" : "array",
- "items" : "ATableDescriptor"
- },
+ "addFamily" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ }, {
+ "name" : "family",
+ "type" : "AFamilyDescriptor"
+ } ],
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "isTableEnabled" : {
+ "deleteFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "family",
+ "type" : "bytes"
} ],
- "response" : "boolean",
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "tableExists" : {
+ "modifyFamily" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "familyName",
+ "type" : "bytes"
+ }, {
+ "name" : "familyDescriptor",
+ "type" : "AFamilyDescriptor"
} ],
- "response" : "boolean",
+ "response" : "null",
"errors" : [ "AIOError" ]
},
- "describeTable" : {
+ "get" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
+ }, {
+ "name" : "get",
+ "type" : "AGet"
} ],
- "response" : "ATableDescriptor",
+ "response" : "AResult",
"errors" : [ "AIOError" ]
},
- "describeFamily" : {
+ "exists" : {
"request" : [ {
"name" : "table",
"type" : "bytes"
}, {
- "name" : "family",
- "type" : "bytes"
+ "name" : "get",
+ "type" : "AGet"
} ],
- "response" : "AFamilyDescriptor",
+ "response" : "boolean",
"errors" : [ "AIOError" ]
},
"put" : {
@@ -511,6 +538,17 @@
"response" : "null",
"errors" : [ "AIOError" ]
},
+ "delete" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ }, {
+ "name" : "delete",
+ "type" : "ADelete"
+ } ],
+ "response" : "null",
+ "errors" : [ "AIOError" ]
+ },
"incrementColumnValue" : {
"request" : [ {
"name" : "table",
@@ -534,17 +572,6 @@
"response" : "long",
"errors" : [ "AIOError" ]
},
- "get" : {
- "request" : [ {
- "name" : "table",
- "type" : "bytes"
- }, {
- "name" : "get",
- "type" : "AGet"
- } ],
- "response" : "AResult",
- "errors" : [ "AIOError" ]
- },
"scannerOpen" : {
"request" : [ {
"name" : "table",
@@ -577,17 +604,6 @@
"items" : "AResult"
},
"errors" : [ "AIOError", "AIllegalArgument" ]
- },
- "delete" : {
- "request" : [ {
- "name" : "table",
- "type" : "bytes"
- }, {
- "name" : "delete",
- "type" : "ADelete"
- } ],
- "response" : "null",
- "errors" : [ "AIOError" ]
}
}
}
View
2  setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name="PyHBase",
- version='0.0.13',
+ version='0.1.0',
description="High-level Python interface to HBase",
url="http://github.com/hammer/pyhbase/",
packages=['pyhbase'],
Please sign in to comment.
Something went wrong with that request. Please try again.