You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ch...@apache.org on 2018/05/02 02:07:03 UTC
hbase git commit: HBASE-20327 When qualifier is not specified,
append and incr operation do not work (shell)
Repository: hbase
Updated Branches:
refs/heads/branch-2.0 31e0cd42a -> 86b763051
HBASE-20327 When qualifier is not specified, append and incr operation do not work (shell)
Signed-off-by: Chia-Ping Tsai <ch...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/86b76305
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/86b76305
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/86b76305
Branch: refs/heads/branch-2.0
Commit: 86b763051becbdea59f50280105c18a0ec379d90
Parents: 31e0cd4
Author: Nihal Jain <ni...@gmail.com>
Authored: Thu Apr 19 02:36:33 2018 +0530
Committer: Chia-Ping Tsai <ch...@gmail.com>
Committed: Wed May 2 09:59:04 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/86b76305/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/86b76305/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')