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:
parent
b3a11b78f7
commit
7fe8a4eadd
|
@ -778,13 +778,16 @@ EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_bytes(bytes, converter_class = nil, converter_method = nil)
|
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
|
end
|
||||||
|
|
||||||
def convert_bytes_with_position(bytes, offset, len, converter_class, converter_method)
|
def convert_bytes_with_position(bytes, offset, len, converter_class, converter_method)
|
||||||
# Avoid nil
|
# Avoid nil
|
||||||
converter_class = 'org.apache.hadoop.hbase.util.Bytes' unless converter_class
|
converter_class ||= 'org.apache.hadoop.hbase.util.Bytes'
|
||||||
converter_method = 'toStringBinary' unless converter_method
|
converter_method ||= 'toStringBinary'
|
||||||
eval(converter_class).method(converter_method).call(bytes, offset, len)
|
eval(converter_class).method(converter_method).call(bytes, offset, len)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -437,6 +437,21 @@ module Hbase
|
||||||
end
|
end
|
||||||
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
|
define_test "scan should work w/o any params" do
|
||||||
|
@ -679,6 +694,21 @@ module Hbase
|
||||||
assert_not_nil(res)
|
assert_not_nil(res)
|
||||||
end
|
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
|
define_test "mutation with TTL should expire" do
|
||||||
@test_table.put('ttlTest', 'x:a', 'foo', { TTL => 1000 } )
|
@test_table.put('ttlTest', 'x:a', 'foo', { TTL => 1000 } )
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue