HBASE-20327 When qualifier is not specified, append and incr operation do not work (shell)
Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
4be96dd8a6
commit
59f6ecd6b2
|
@ -251,14 +251,12 @@ EOF
|
|||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Increment a counter atomically
|
||||
# rubocop:disable Metrics/AbcSize, CyclomaticComplexity, MethodLength
|
||||
def _incr_internal(row, column, value = nil, args = {})
|
||||
value = 1 if value.is_a?(Hash)
|
||||
value ||= 1
|
||||
incr = org.apache.hadoop.hbase.client.Increment.new(row.to_s.to_java_bytes)
|
||||
family, qualifier = parse_column_name(column)
|
||||
if qualifier.nil?
|
||||
raise ArgumentError, 'Failed to provide both column family and column qualifier for incr'
|
||||
end
|
||||
if args.any?
|
||||
attributes = args[ATTRIBUTES]
|
||||
visibility = args[VISIBILITY]
|
||||
|
@ -282,9 +280,6 @@ EOF
|
|||
def _append_internal(row, column, value, args = {})
|
||||
append = org.apache.hadoop.hbase.client.Append.new(row.to_s.to_java_bytes)
|
||||
family, qualifier = parse_column_name(column)
|
||||
if qualifier.nil?
|
||||
raise ArgumentError, 'Failed to provide both column family and column qualifier for append'
|
||||
end
|
||||
if args.any?
|
||||
attributes = args[ATTRIBUTES]
|
||||
visibility = args[VISIBILITY]
|
||||
|
@ -302,6 +297,7 @@ EOF
|
|||
org.apache.hadoop.hbase.util.Bytes.toStringBinary(cell.getValueArray,
|
||||
cell.getValueOffset, cell.getValueLength)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize, CyclomaticComplexity, MethodLength
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Count rows in a table
|
||||
|
|
|
@ -186,7 +186,19 @@ module Hbase
|
|||
@test_table.append("123", 'x:cnt2', '123')
|
||||
assert_equal("123123", @test_table._append_internal("123", 'x:cnt2', '123'))
|
||||
end
|
||||
|
||||
define_test 'append should work without qualifier' do
|
||||
@test_table.append('1001', 'x', '123')
|
||||
assert_equal('123321', @test_table._append_internal('1001', 'x', '321'))
|
||||
end
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
define_test 'incr should work without qualifier' do
|
||||
@test_table.incr('1010', 'x', 123)
|
||||
assert_equal(123, @test_table._get_counter_internal('1010', 'x'))
|
||||
@test_table.incr('1010', 'x', 123)
|
||||
assert_equal(246, @test_table._get_counter_internal('1010', 'x'))
|
||||
end
|
||||
|
||||
define_test "get_counter should work with integer keys" do
|
||||
@test_table.incr(12345, 'x:cnt')
|
||||
|
|
Loading…
Reference in New Issue