Reputation: 9681
I want to convert a String to a Ruby byte array. I have a String and saving it in Hbase as binary byte array. Need to scan with some filter on key which is a binary byte array. Have a String like "U92w8GSBJ2BiHzGg" and need its representation like "\xFF\xA4\xDD\x13\x003\xE4\x85\xC7\x9D\xD5ZY\xF0\x1E" so that I can make query on Hbase shell like below
hbase(main):005:0> scan 't1', {FILTER => "(PrefixFilter ('\xFF\xA4\xDD\x13\x003\xE4')"}
Thanks in advance
Upvotes: 1
Views: 582
Reputation: 137
The correct way to do it is to use double quotes for JRuby byte strings. For example:
"\xFF\xA4\xDD\x13\x003\xE4"
(I know this reply is late, but I had the same problem and stumbled upon this solution)
Upvotes: 0
Reputation: 7181
I want to convert a String to a Ruby byte array.
will assume you mean: "want to convert a Ruby String to a Java byte array"
simply use 'a_ruby_binary_string'.to_java_bytes
(returns byte[]
under JRuby)
Upvotes: 1