Author: apurtell Date: Sun Dec 20 19:50:28 2009 New Revision: 892649 URL: http://svn.apache.org/viewvc?rev=892649&view=rev Log: HBASE-2028 Add HTable.incrementColumnValue support to shell
Modified: hadoop/hbase/branches/0.20/CHANGES.txt hadoop/hbase/branches/0.20/bin/HBase.rb hadoop/hbase/branches/0.20/bin/hirb.rb Modified: hadoop/hbase/branches/0.20/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=892649&r1=892648&r2=892649&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/CHANGES.txt (original) +++ hadoop/hbase/branches/0.20/CHANGES.txt Sun Dec 20 19:50:28 2009 @@ -50,6 +50,8 @@ HBASE-2049 Cleanup HLog binary log output (Dave Latham via Stack) HBASE-2060 Missing closing tag in mapreduce package info (Lars George via Andrew Purtell) + HBASE-2028 Add HTable.incrementColumnValue support to shell (Lars George + via Andrew Purtell) Release 0.20.2 - November 18th, 2009 INCOMPATIBLE CHANGES Modified: hadoop/hbase/branches/0.20/bin/HBase.rb URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/bin/HBase.rb?rev=892649&r1=892648&r2=892649&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/bin/HBase.rb (original) +++ hadoop/hbase/branches/0.20/bin/HBase.rb Sun Dec 20 19:50:28 2009 @@ -462,6 +462,22 @@ @formatter.footer(now) 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() tn = @table.getTableName() return Bytes.equals(tn, HConstants::META_TABLE_NAME) || @@ -619,6 +635,12 @@ if formatter.rowCount() != 3 raise IOError.new("Failed endrow test") 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 table.delete('x1', 'x:1'); table.scan(['x:1']) Modified: hadoop/hbase/branches/0.20/bin/hirb.rb URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/bin/hirb.rb?rev=892649&r1=892648&r2=892649&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/bin/hirb.rb (original) +++ hadoop/hbase/branches/0.20/bin/hirb.rb Sun Dec 20 19:50:28 2009 @@ -234,6 +234,14 @@ hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, \\ 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 put Put a cell 'value' at specified table/row/column and optionally @@ -401,6 +409,10 @@ table(table).put(row, column, value, timestamp) end +def incr(table, row, column, value = nil) + table(table).incr(row, column, value) +end + def scan(table, args = {}) table(table).scan(args) end