use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adapt.
/**
* adapt.
*
* @param scan a {@link Scan} object.
* @return a {@link Query} object.
*/
public Query adapt(Scan scan) {
ReadHooks readHooks = new DefaultReadHooks();
Query query = Query.create(getTableId());
Adapters.SCAN_ADAPTER.adapt(scan, readHooks, query);
readHooks.applyPreSendHook(query);
return query;
}
use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.
the class TestWhileMatchFilterAdapter method notSupported_inInterleave.
@Test
public void notSupported_inInterleave() {
QualifierFilter qualifierFilter = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("x")));
WhileMatchFilter whileMatchFilter = new WhileMatchFilter(qualifierFilter);
FilterList list = new FilterList(Operator.MUST_PASS_ONE, whileMatchFilter);
Scan scan = new Scan();
scan.setFilter(list);
FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
assertFalse(instance.isFilterSupported(context, whileMatchFilter).isSupported());
}
use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.
the class TestWhileMatchFilterAdapter method wrappedFilterNotSupported.
@Test
public void wrappedFilterNotSupported() {
FilterBase notSupported = new FilterBase() {
@Override
public ReturnCode filterKeyValue(Cell v) throws IOException {
return null;
}
};
WhileMatchFilter filter = new WhileMatchFilter(notSupported);
Scan scan = new Scan();
scan.setFilter(filter);
FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
assertFalse(instance.isFilterSupported(context, filter).isSupported());
}
use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.
the class TestWhileMatchFilterAdapter method supported_inChain.
@Test
public void supported_inChain() {
QualifierFilter qualifierFilterY = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("y")));
FilterList interleaveList = new FilterList(Operator.MUST_PASS_ONE, qualifierFilterY);
QualifierFilter qualifierFilterX = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("x")));
WhileMatchFilter whileMatchFilter = new WhileMatchFilter(qualifierFilterX);
FilterList chainList = new FilterList(Operator.MUST_PASS_ALL, whileMatchFilter, interleaveList);
Scan scan = new Scan();
scan.setFilter(chainList);
FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
assertTrue(instance.isFilterSupported(context, whileMatchFilter).isSupported());
}
use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.
the class TestFilterListAdapter method testPageFilter.
@Test
public /**
* FilterListAdapter should handle the fact that PageFilterAdapter returns null.
*/
void testPageFilter() throws IOException {
byte[] qualA = Bytes.toBytes("qualA");
PageFilter pageFilter = new PageFilter(20);
FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(qualA)), pageFilter);
FilterAdapter adapter = FilterAdapter.buildAdapter();
Optional<Filters.Filter> adapted = adapter.adaptFilter(new FilterAdapterContext(new Scan(), new DefaultReadHooks()), filterList);
Assert.assertTrue(adapted.isPresent());
Optional<Filters.Filter> qualifierAdapted = adapter.adaptFilter(new FilterAdapterContext(new Scan(), new DefaultReadHooks()), filterList.getFilters().get(0));
Assert.assertEquals(qualifierAdapted.get().toProto(), adapted.get().toProto());
}
Aggregations