2
votes

I have a HBase table containing the following row key format:

<salt>:<id>#<category>#<class>

000001:1234#AAAAAAAAAA#BBBBBBB
000001:2345#CCCCCCCCCC#DDDDDDD
000002:1234#EEEEEEEEEE#FFFFFFF
...

I'd like to make a Scan on the Row Keys and get all the rows where the key contains id=1234. Is it possible to add a regex or a SubstringComparator to the PrefixFilter (the PrefixFilter worked perfectly for the id filtering before I added the salt value in front of the key)?

Or are there other possibilities to search for this key part?

1

1 Answers

2
votes

You need a RowFilter with RegexStringComparator:

import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.RegexStringComparator;
import org.apache.hadoop.hbase.filter.RowFilter;

RowFilter filter = new RowFilter(
    CompareFilter.CompareOp.EQUAL, 
    new RegexStringComparator("your_regexp")
);