HBASE-10728 get_counter value is never used.

This commit is contained in:
Lars George 2015-03-28 10:46:23 +01:00
parent bfb04d26a7
commit 7f8745453e
3 changed files with 29 additions and 20 deletions

View File

@ -219,7 +219,12 @@ EOF
set_op_ttl(incr, ttl) if ttl set_op_ttl(incr, ttl) if ttl
end end
incr.addColumn(family, qualifier, value) incr.addColumn(family, qualifier, value)
@table.increment(incr) result = @table.increment(incr)
return nil if result.isEmpty
# Fetch cell value
cell = result.listCells[0]
org.apache.hadoop.hbase.util.Bytes::toLong(cell.getValue)
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------

View File

@ -23,8 +23,8 @@ module Shell
def help def help
return <<-EOF return <<-EOF
Return a counter cell value at specified table/row/column coordinates. Return a counter cell value at specified table/row/column coordinates.
A cell cell should be managed with atomic increment function oh HBase A counter cell should be managed with atomic increment functions on HBase
and the data should be binary encoded. Example: and the data should be binary encoded (as long value). Example:
hbase> get_counter 'ns1:t1', 'r1', 'c1' hbase> get_counter 'ns1:t1', 'r1', 'c1'
hbase> get_counter 't1', 'r1', 'c1' hbase> get_counter 't1', 'r1', 'c1'
@ -36,11 +36,11 @@ t to table 't1', the corresponding command would be:
EOF EOF
end end
def command(table, row, column, value) def command(table, row, column)
get_counter(table(table), row, column, value) get_counter(table(table), row, column)
end end
def get_counter(table, row, column, value = nil) def get_counter(table, row, column)
if cnt = table._get_counter_internal(row, column) if cnt = table._get_counter_internal(row, column)
puts "COUNTER VALUE = #{cnt}" puts "COUNTER VALUE = #{cnt}"
else else

View File

@ -50,7 +50,11 @@ EOF
def incr(table, row, column, value = nil, args={}) def incr(table, row, column, value = nil, args={})
format_simple_command do format_simple_command do
table._incr_internal(row, column, value, args) if cnt = table._incr_internal(row, column, value, args)
puts "COUNTER VALUE = #{cnt}"
else
puts "No counter found at specified coordinates"
end
end end
end end
end end