From 59f6ecd6b2155f65fa9d0b6a8bae47fec0ecbeb4 Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Thu, 19 Apr 2018 02:36:33 +0530 Subject: [PATCH] HBASE-20327 When qualifier is not specified, append and incr operation do not work (shell) Signed-off-by: Chia-Ping Tsai --- hbase-shell/src/main/ruby/hbase/table.rb | 8 ++------ hbase-shell/src/test/ruby/hbase/table_test.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index d12b30f57fc..55211b00561 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -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 diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index 08857615e35..9b15f839f9e 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -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')