From 8c313d5be46a02c212d38a1ee782cbff570f007f Mon Sep 17 00:00:00 2001 From: Guangxu Cheng Date: Tue, 23 May 2017 19:34:58 +0800 Subject: [PATCH] HBASE-18094 Display the return value of the command append Signed-off-by: tedyu --- hbase-shell/src/main/ruby/hbase/table.rb | 7 ++++++- hbase-shell/src/main/ruby/shell/commands/append.rb | 6 ++++-- hbase-shell/src/test/ruby/hbase/table_test.rb | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 057adca5eb8..36c650984fd 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -244,7 +244,12 @@ EOF set_op_ttl(append, ttl) if ttl end append.add(family, qualifier, value.to_s.to_java_bytes) - @table.append(append) + result = @table.append(append) + return nil if result.isEmpty + + # Fetch cell value + cell = result.listCells[0] + org.apache.hadoop.hbase.util.Bytes::toStringBinary(cell.getValue) end #---------------------------------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/append.rb b/hbase-shell/src/main/ruby/shell/commands/append.rb index a0ef36d28e0..adf11843694 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append.rb @@ -40,8 +40,10 @@ EOF end def append(table, row, column, value, args={}) - format_simple_command do - table._append_internal(row, column, value, args) + format_simple_command do + if current_value = table._append_internal(row, column, value, args) + puts "CURRENT VALUE = #{current_value}" + end end end end diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index 0fb5a14193a..b6801da354b 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -183,6 +183,7 @@ module Hbase define_test "append should work with value" do @test_table.append("123", 'x:cnt2', '123') + assert_equal("123123", @test_table._append_internal("123", 'x:cnt2', '123')) end #-------------------------------------------------------------------------------