use of com.google.cloud.bigtable.data.v2.models.Filters.Filter in project java-bigtable-hbase by googleapis.
the class ColumnPaginationFilterAdapter method createChain.
/**
* Create a filter chain that allows the latest values for each qualifier, those cells that pass
* an option intermediate filter and are less than the limit per row.
*/
private Filter createChain(ColumnPaginationFilter filter, Filter intermediate) {
ChainFilter chain = FILTERS.chain();
chain.filter(FILTERS.limit().cellsPerColumn(1));
if (intermediate != null) {
chain.filter(intermediate);
}
chain.filter(FILTERS.limit().cellsPerRow(filter.getLimit()));
return chain;
}
use of com.google.cloud.bigtable.data.v2.models.Filters.Filter in project java-bigtable-hbase by googleapis.
the class FuzzyRowFilterAdapter method adapt.
/**
* {@inheritDoc}
*/
@Override
public Filter adapt(FilterAdapterContext context, FuzzyRowFilter filter) throws IOException {
List<Pair<byte[], byte[]>> pairs = extractFuzzyRowFilterPairs(filter);
if (pairs.isEmpty()) {
return FILTERS.pass();
}
InterleaveFilter interleave = FILTERS.interleave();
for (Pair<byte[], byte[]> pair : pairs) {
Preconditions.checkArgument(pair.getFirst().length == pair.getSecond().length, "Fuzzy info and match mask must have the same length");
interleave.filter(createSingleRowFilter(pair.getFirst(), pair.getSecond()));
}
return interleave;
}
use of com.google.cloud.bigtable.data.v2.models.Filters.Filter in project java-bigtable-hbase by googleapis.
the class MultipleColumnPrefixFilterAdapter method adapt.
/**
* {@inheritDoc}
*/
@Override
public Filter adapt(FilterAdapterContext context, MultipleColumnPrefixFilter filter) throws IOException {
InterleaveFilter interleave = FILTERS.interleave();
ByteString.Output outputStream = null;
for (byte[] prefix : filter.getPrefix()) {
if (outputStream == null) {
outputStream = ByteString.newOutput(prefix.length * 2);
} else {
outputStream.reset();
}
ReaderExpressionHelper.writeQuotedExpression(outputStream, prefix);
outputStream.write(ReaderExpressionHelper.ALL_QUALIFIERS_BYTES);
interleave.filter(FILTERS.qualifier().regex(outputStream.toByteString()));
}
return interleave;
}
use of com.google.cloud.bigtable.data.v2.models.Filters.Filter in project java-bigtable-hbase by googleapis.
the class TestQualifierFilterAdapter method assertAdaptedForm.
private void assertAdaptedForm(ByteArrayComparable comparable, CompareFilter.CompareOp op, Filters.Filter expectedFilter) throws IOException {
QualifierFilter filter = new QualifierFilter(op, comparable);
Filters.Filter actualFilter = adapter.adapt(scanWithOnFamilyScanContext, filter);
Assert.assertEquals(expectedFilter.toProto(), actualFilter.toProto());
}
use of com.google.cloud.bigtable.data.v2.models.Filters.Filter in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilterAdapter method latestVersionOnlyComparisonsAreDone.
@Test
public void latestVersionOnlyComparisonsAreDone() throws IOException {
byte[] filterValue = Bytes.toBytes("foobar");
byte[] qualifier = Bytes.toBytes("someColumn");
byte[] family = Bytes.toBytes("f");
SingleColumnValueFilter filter = new SingleColumnValueFilter(family, qualifier, CompareFilter.CompareOp.EQUAL, new BinaryComparator(filterValue));
filter.setFilterIfMissing(false);
filter.setLatestVersionOnly(true);
Filters.Filter adaptedFilter = UNDER_TEST.adapt(new FilterAdapterContext(new Scan(), null), filter);
assertFilterIfNotMIssingMatches(family, qualifier, filterValue, true, adaptedFilter);
}
Aggregations