简体   繁体   中英

Hbase multiple partial rowkeys scan

I am trying find a solution to scan a Hbase table, with multiple partial keys from the same rowkey.

example:

RowKey: account_id|name|age|transaction_date
             12345|abc |50 |2016-05-05 08:10:10

Here I want to scan a hbase table to get all the possible values with the following partial key combination:

Rowkey: account_id|transation_date
             12345|2016-05-05 08:10:10

you can use prefix filter. ... some thing like below.

prefixfilter:

This filter takes one argument a prefix of a row key. It returns only those key-values present in a row that starts with the specified row prefix

Syntax

PrefixFilter (<row_prefix>)

Same can be used with java client as well

scan 'yourtable', {FILTER => "PrefixFilter('12345|abc|50|2016-05-05')"}

scan 'yourtable', {STARTROW=>'12345' FILTER => "PrefixFilter('2016-05-05 08:10:10')"}
OR 
scan 'yourtable', {ENDROW='2016-05-05 08:10:10'"}

based on your requirement...

NOTE : java hbase scan api also has same methods if you want to do it from java

您可以将RowFilter与regexstring一起使用。

scan ‘myTable’, {FILTER => "RowFilter(=, 'regexstring:12345.*2016-05-05 08:10:10’)”}

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