For a table that has a composite row key of two integers, what should be the command to get a row from hbase shell.
I have created this sample ruby script
include Java
import org.apache.hadoop.hbase.util.Bytes
id = ARGV[0]
sid = ARGV[1]
byte [] rowkey = Bytes.add(Bytes.toBytes(id.to_i),Bytes.toBytes(sid.to_i))
puts Bytes.toStringBinary (rowkey)
....
....
....
The output I see when I call hbase org.jruby.Main script.rb 10 20
\x00\x00\x00\x00\x00\x00\x00\x0A\x00\x00\x00\x00\x00\x00\x00\x14 which clearly show 16 bytes long. How do I ensure that it is 8 bytes long (4 for id, 4 for sid).
This is because
toBytesis overloaded to accept bothlongandintarguments, and JRuby always convertsFixnumtolong. There is no way to choose the overload with theintargument.Instead you must use an alternate way to create the array. First initialize an empty array, and then add each ID: