HBASE-21178 [BC break] : Get and Scan operation with a custom converter_class not working

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
subrat.mishra 2018-09-18 11:03:53 +05:30 committed by tedyu
parent fa5fa6ecdd
commit 05f8bea620
2 changed files with 36 additions and 3 deletions

View File

@ -778,13 +778,16 @@ EOF
end
def convert_bytes(bytes, converter_class = nil, converter_method = nil)
convert_bytes_with_position(bytes, 0, bytes.length, converter_class, converter_method)
# Avoid nil
converter_class ||= 'org.apache.hadoop.hbase.util.Bytes'
converter_method ||= 'toStringBinary'
eval(converter_class).method(converter_method).call(bytes)
end
def convert_bytes_with_position(bytes, offset, len, converter_class, converter_method)
# Avoid nil
converter_class = 'org.apache.hadoop.hbase.util.Bytes' unless converter_class
converter_method = 'toStringBinary' unless converter_method
converter_class ||= 'org.apache.hadoop.hbase.util.Bytes'
converter_method ||= 'toStringBinary'
eval(converter_class).method(converter_method).call(bytes, offset, len)
end

View File

@ -437,6 +437,21 @@ module Hbase
end
end
define_test 'get should work with a custom converter class' do
@test_table.put(1, 'x:v', 1234)
begin
res = @test_table._get_internal('1', 'COLUMNS' =>
['x:v:c(org.apache.hadoop.hbase.util.Bytes).len'])
assert_not_nil(res)
assert_kind_of(Hash, res)
assert_not_nil(res['x:v'])
assert_not_nil(/value=4/.match(res['x:v']))
ensure
# clean up newly added columns for this test only.
@test_table.deleteall(1, 'x:v')
end
end
#-------------------------------------------------------------------------------
define_test "scan should work w/o any params" do
@ -679,6 +694,21 @@ module Hbase
assert_not_nil(res)
end
define_test 'scan should work with a custom converter class' do
@test_table.put(1, 'x:v', 1234)
begin
res = @test_table._scan_internal 'COLUMNS' =>
['x:v:c(org.apache.hadoop.hbase.util.Bytes).len']
assert_not_nil(res)
assert_kind_of(Hash, res)
assert_not_nil(res['1']['x:v'])
assert_not_nil(/value=4/.match(res['1']['x:v']))
ensure
# clean up newly added columns for this test only.
@test_table.deleteall(1, 'x:v')
end
end
define_test "mutation with TTL should expire" do
@test_table.put('ttlTest', 'x:a', 'foo', { TTL => 1000 } )
begin