1

How do you use the hbase shell scan command when your row key is hashed?

I have a dummy instance working on a sandbox (where the row key is not hashed) with the following command.

    scan 'tableName' , {ROWPREFIXFILTER => 'myrowStartValue'}

and this works. However, for the real instance the row key is hashed. How to solve this?

IncompleteCoder
  • 153
  • 1
  • 12

2 Answers2

1

I would expect to have one record only but it may be a range.

scan 'mytablename',{FILTER=>org.apache.hadoop.hbase.filter.PrefixFilter.new(org.apache.hadoop.hbase.util.Bytes.toBytes(org.apache.hadoop.hbase.util.MD5Hash.getMD5AsHex(org.apache.hadoop.hbase.util.Bytes.toBytes('somekeyvalueprefix'))))}

I did find that we can use the hbase classes at the command line. However, I didn't get the value I expected.

IncompleteCoder
  • 153
  • 1
  • 12
0

Are you expecting a range of keys to be returned? Once they're hashed, they'll no longer be ordered in the way you expect, and so a scan might not do what you expect. I'm afraid you'll have to manually hash any keys you want to retrieve in advance - HBase shell can't do this for you.

Ben Watson
  • 5,357
  • 4
  • 42
  • 65