I have an HBase scan with a ColumnPrefixFilter
and multiple FuzzyFilter
s like so:
FilterList filterList = new FilterList();
filterList.addFilter(new FuzzyFilter(...));
filterList.addFilter(new FuzzyFilter(...));
filterList.addFilter(new ColumnPrefixFilter(...));
Scan s = new Scan();
s.setFilter(filterList);
Is there a way I can use MUST_PASS_ONE
on the FuzzyFilter
s and then a MUST_PASS_ALL
on the ColumnPrefixFilter
combined with the set of FuzzyFilter
s?
So I'm looking for something like this:
ColumnPrefixFilter
AND (FuzzyFilter
OR FuzzyFilter
)
We can implement two different FilterList to acheive this. Refer the below code
FilterList mainFilter = new FilterList(FilterList.Operator.MUST_PASS_ALL);
FilterList subFilter = new FilterList(FilterList.Operator.MUST_PASS_ONE);
subFilter.addFilter(new FuzzyRowFilter(null));
subFilter.addFilter(new FuzzyRowFilter(null));
mainFilter.addFilter(new ColumnPrefixFilter(Bytes.toBytes("d")));
mainFilter.addFilter(subFilter);
You can define a mainFilter with MUST_PASS_ALL operator and a subFilter with MUST_PASS_ONE. Now add the filter conditions into subFilter and then add back this subFilter into mainFilter.
FilterList
is a Filter
itself, so just combine them
FilterList fuzzy = new FilterList(MUST_PASS_ONE, fuzzy1, fuzzy2);
FilterList main = new FilterList(MUST_PASS_ALL, prefixFilter, fuzzy);
s.setFilter(main);