hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [13/43] hbase git commit: HBASE-20327 When qualifier is not specified, append and incr operation do not work (shell)
Date Wed, 02 May 2018 02:59:03 GMT
HBASE-20327 When qualifier is not specified, append and incr operation do not work (shell)

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/59f6ecd6
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/59f6ecd6
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/59f6ecd6

Branch: refs/heads/HBASE-19064
Commit: 59f6ecd6b2155f65fa9d0b6a8bae47fec0ecbeb4
Parents: 4be96dd
Author: Nihal Jain <nihaljain.cs@gmail.com>
Authored: Thu Apr 19 02:36:33 2018 +0530
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Sat Apr 28 12:55:30 2018 +0800

----------------------------------------------------------------------
 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(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/59f6ecd6/hbase-shell/src/main/ruby/hbase/table.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb
index d12b30f..55211b0 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

http://git-wip-us.apache.org/repos/asf/hbase/blob/59f6ecd6/hbase-shell/src/test/ruby/hbase/table_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb
index 0885761..9b15f83 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')


Mime
View raw message