简体   繁体   中英

How to use hbase-shell scan command when row key is hashed

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM