Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added incr

  • Loading branch information...
commit 375de9055234995ecec5cfd516a30e4d0a25304b 1 parent aa3747e
@hammer hammer authored
View
6 examples/pyhbase-cli
@@ -28,6 +28,7 @@ if __name__=="__main__":
flush table
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
@@ -133,6 +134,11 @@ if __name__=="__main__":
usage()
sys.exit(1)
print connection.put(*args)
+ elif cmd == 'incr':
+ if len(args) not in [3, 4]:
+ usage()
+ sys.exit(1)
+ print connection.incr(*args)
elif cmd == 'scan':
if len(args) != 2:
usage()
View
8 pyhbase/connection.py
@@ -164,6 +164,14 @@ def put(self, table, row, *column_values):
params = {"table": table, "put": put}
return self.requestor.request("put", params)
+ @retry_wrapper
+ def incr(self, table, row, *column_and_amount):
+ family, qualifier = column_and_amount[0].split(":")
+ amount = 1
+ if len(column_and_amount) > 1:
+ amount = column_and_amount[1]
+ return self.requestor.request("incrementColumnValue", {"table": table, "row": row, "family": family, "qualifier": qualifier, "amount": int(amount), "writeToWAL": True})
+
#
# Delete
#
View
23 pyhbase/schema/hbase.avpr
@@ -511,6 +511,29 @@
"response" : "null",
"errors" : [ "AIOError" ]
},
+ "incrementColumnValue" : {
+ "request" : [ {
+ "name" : "table",
+ "type" : "bytes"
+ }, {
+ "name" : "row",
+ "type" : "bytes"
+ }, {
+ "name" : "family",
+ "type" : "bytes"
+ }, {
+ "name" : "qualifier",
+ "type" : "bytes"
+ }, {
+ "name" : "amount",
+ "type" : "long"
+ }, {
+ "name" : "writeToWAL",
+ "type" : "boolean"
+ } ],
+ "response" : "long",
+ "errors" : [ "AIOError" ]
+ },
"get" : {
"request" : [ {
"name" : "table",
View
2  setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name="PyHBase",
- version='0.0.12',
+ version='0.0.13',
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.