From 349dd5e214d811c7fd6a40b8e3949b64e7389763 Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Sat, 4 Nov 2017 11:02:19 +0800 Subject: [PATCH] HBASE-19178 table.rb use undefined method 'getType' for Cell interface --- hbase-shell/src/main/ruby/hbase/table.rb | 2 +- hbase-shell/src/test/ruby/hbase/table_test.rb | 41 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 320ec7c7aef..07c74d81906 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -749,7 +749,7 @@ EOF end if org.apache.hadoop.hbase.CellUtil.isDelete(kv) - val = "timestamp=#{kv.getTimestamp}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getType)}" + val = "timestamp=#{kv.getTimestamp}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}" else val = "timestamp=#{kv.getTimestamp}, value=#{convert(column, kv, converter_class, converter)}" end diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index 81d0a9a678b..e7e1b23e410 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -557,22 +557,41 @@ module Hbase @test_table.put(2, "x:raw1", 11) args = {} - numRows = 0 - count = @test_table._scan_internal(args) do |row, cells| # Normal Scan - numRows += 1 + num_rows = 0 + @test_table._scan_internal(args) do # Normal Scan + num_rows += 1 end - assert_equal(numRows, 2, "Num rows scanned without RAW/VERSIONS are not 2") + assert_equal(num_rows, 2, + 'Num rows scanned without RAW/VERSIONS are not 2') - args = {VERSIONS=>10,RAW=>true} # Since 4 versions of row with rowkey 2 is been added, we can use any number >= 4 for VERSIONS to scan all 4 versions. - numRows = 0 - count = @test_table._scan_internal(args) do |row, cells| # Raw Scan - numRows += 1 + args = { VERSIONS => 10, RAW => true } # Since 4 versions of row with rowkey 2 is been added, we can use any number >= 4 for VERSIONS to scan all 4 versions. + num_rows = 0 + @test_table._scan_internal(args) do # Raw Scan + num_rows += 1 end - assert_equal(numRows, 5, "Num rows scanned without RAW/VERSIONS are not 5") # 5 since , 1 from row key '1' and other 4 from row key '4' + # 5 since , 1 from row key '1' and other 4 from row key '4' + assert_equal(num_rows, 5, + 'Num rows scanned without RAW/VERSIONS are not 5') + + @test_table.delete(1, 'x:a') + args = {} + num_rows = 0 + @test_table._scan_internal(args) do # Normal Scan + num_rows += 1 + end + assert_equal(num_rows, 1, + 'Num rows scanned without RAW/VERSIONS are not 1') + + args = { VERSIONS => 10, RAW => true } + num_rows = 0 + @test_table._scan_internal(args) do # Raw Scan + num_rows += 1 + end + # 6 since , 2 from row key '1' and other 4 from row key '4' + assert_equal(num_rows, 6, + 'Num rows scanned without RAW/VERSIONS are not 5') end - - define_test "scan should fail on invalid COLUMNS parameter types" do assert_raise(ArgumentError) do @test_table._scan_internal COLUMNS => {}