HBASE-10728 get_counter value is never used.
This commit is contained in:
parent
bfb04d26a7
commit
7f8745453e
|
@ -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
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue