HBase prefixFilter works with startRow and PageFilter

360 views Asked by At

In Hbase, I have rowkey like this : userId:timestamp:objectId. I'm trying to create a method like this:

public List<Object> getObjectList(String userId, String startrowA, int limit) 

I want to get records with prefix userId, and also have paging(startrow+limit).

So how I use prefixFilter, pageFilter to do this? Thanks

1

There are 1 answers

0
VS_FF On

If I understood your question correctly, you can try using the FilterList class and add to it a few filters that collectively will allow you to achieve what you are looking for. Try adding the following filters to your FilterList:

KeyOnlyFilter(): only scan rows, not columns (to make it faster)

FirstKeyOnlyFilter(): same as above, use both of them

PrefixFilter(prefix): that's your prefix

PageFilter(N): return only N rows

Also, make sure to set the right condition setting (i.e. whether all these conditions should be met or some of them). To make all of them meet, use FilterList.Operator.MUST_PASS_ALL