HBASE-2028 Add HTable.incrementColumnValue support to shell

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@892648 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-12-20 19:50:23 +00:00
parent ed377a19e3
commit c609d25614
3 changed files with 36 additions and 0 deletions

View File

@ -245,6 +245,8 @@ Release 0.21.0 - Unreleased
HBASE-2059 Break out WAL reader and writer impl from HLog HBASE-2059 Break out WAL reader and writer impl from HLog
HBASE-2060 Missing closing tag in mapreduce package info (Lars George via HBASE-2060 Missing closing tag in mapreduce package info (Lars George via
Andrew Purtell) Andrew Purtell)
HBASE-2028 Add HTable.incrementColumnValue support to shell (Lars George
via Andrew Purtell)
NEW FEATURES NEW FEATURES
HBASE-1901 "General" partitioner for "hbase-48" bulk (behind the api, write HBASE-1901 "General" partitioner for "hbase-48" bulk (behind the api, write

View File

@ -460,6 +460,22 @@ module HBase
@formatter.footer(now) @formatter.footer(now)
end end
def incr(row, column, value = nil)
now = Time.now
split = KeyValue.parseColumn(column.to_java_bytes)
family = split[0]
qualifier = nil
if split.length > 1
qualifier = split[1]
end
if value == nil
value = 1
end
@table.incrementColumnValue(row.to_java_bytes, family, qualifier, value)
@formatter.header()
@formatter.footer(now)
end
def isMetaTable() def isMetaTable()
tn = @table.getTableName() tn = @table.getTableName()
return Bytes.equals(tn, HConstants::META_TABLE_NAME) || return Bytes.equals(tn, HConstants::META_TABLE_NAME) ||
@ -621,6 +637,12 @@ module HBase
if formatter.rowCount() != 3 if formatter.rowCount() != 3
raise IOError.new("Failed endrow test") raise IOError.new("Failed endrow test")
end end
# Verify that incr works
table.incr('incr1', 'c:1');
table.scan({COLUMNS => ['c:1']})
if formatter.rowCount() != 1
raise IOError.new("Failed incr test")
end
# Verify that delete works # Verify that delete works
table.delete('x1', 'x:1'); table.delete('x1', 'x:1');
table.scan({COLUMNS => ['x:1']}) table.scan({COLUMNS => ['x:1']})

View File

@ -234,6 +234,14 @@ HBASE SHELL COMMANDS:
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, \\ hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, \\
VERSIONS => 4} VERSIONS => 4}
incr Increments a cell 'value' at specified table/row/column coordinates.
To increment a cell value in table 't1' at row 'r1' under column
'c1' by 1 (can be omitted) or 10 do:
hbase> incr 't1', 'r1', 'c1'
hbase> incr 't1', 'r1', 'c1', 1
hbase> incr 't1', 'r1', 'c1', 10
list List all tables in hbase list List all tables in hbase
put Put a cell 'value' at specified table/row/column and optionally put Put a cell 'value' at specified table/row/column and optionally
@ -401,6 +409,10 @@ def put(table, row, column, value, timestamp = nil)
table(table).put(row, column, value, timestamp) table(table).put(row, column, value, timestamp)
end end
def incr(table, row, column, value = nil)
table(table).incr(row, column, value)
end
def scan(table, args = {}) def scan(table, args = {})
table(table).scan(args) table(table).scan(args)
end end