Search in sources :

Example 11 with DefaultReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method mustPassAllIsNotSupportedBelowTopLevel.

@Test
public void mustPassAllIsNotSupportedBelowTopLevel() {
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), new DefaultReadHooks());
    PageFilter pageFilter = new PageFilter(20);
    FilterList secondLevelList = new FilterList(Operator.MUST_PASS_ALL, pageFilter);
    FilterList topLevelList = new FilterList(Operator.MUST_PASS_ALL, secondLevelList);
    try (ContextCloseable ignored = context.beginFilterList(topLevelList)) {
        try (ContextCloseable evenMoreIgnored = context.beginFilterList(secondLevelList)) {
            FilterSupportStatus status = pageFilterAdapter.isFilterSupported(context, pageFilter);
            Assert.assertFalse("MUST_PASS_ALL should not be supported lower than top level.", status.isSupported());
        }
    }
}
Also used : ContextCloseable(com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable) Scan(org.apache.hadoop.hbase.client.Scan) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Test(org.junit.Test)

Example 12 with DefaultReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method pageFilterIsAppliedToReadRowsRequest.

@Test
public void pageFilterIsAppliedToReadRowsRequest() throws IOException {
    final String TABLE_ID = "tableId";
    final RequestContext requestContext = RequestContext.create("ProjectId", "InstanceId", "AppProfile");
    ReadHooks hooks = new DefaultReadHooks();
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), hooks);
    PageFilter pageFilter = new PageFilter(20);
    Filters.Filter adaptedFilter = pageFilterAdapter.adapt(context, pageFilter);
    Assert.assertNull("PageFilterAdapter should not return a Filters.Filter.", adaptedFilter);
    Query query = Query.create(TABLE_ID).limit(100);
    hooks.applyPreSendHook(query);
    Assert.assertEquals(20, query.toProto(requestContext).getRowsLimit());
}
Also used : Filters(com.google.cloud.bigtable.data.v2.models.Filters) ReadHooks(com.google.cloud.bigtable.hbase.adapters.read.ReadHooks) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Query(com.google.cloud.bigtable.data.v2.models.Query) Scan(org.apache.hadoop.hbase.client.Scan) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) RequestContext(com.google.cloud.bigtable.data.v2.internal.RequestContext) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Test(org.junit.Test)

Example 13 with DefaultReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.

the class TestWhileMatchFilterAdapter method notSupported_inChain_inInterleave.

@Test
public void notSupported_inChain_inInterleave() {
    QualifierFilter qualifierFilter = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("x")));
    WhileMatchFilter whileMatchFilter = new WhileMatchFilter(qualifierFilter);
    FilterList chainList = new FilterList(Operator.MUST_PASS_ALL, whileMatchFilter);
    FilterList interleaveList = new FilterList(Operator.MUST_PASS_ONE, chainList);
    Scan scan = new Scan();
    scan.setFilter(interleaveList);
    FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
    assertFalse(instance.isFilterSupported(context, whileMatchFilter).isSupported());
}
Also used : WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) Scan(org.apache.hadoop.hbase.client.Scan) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) Test(org.junit.Test)

Example 14 with DefaultReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.

the class TestWhileMatchFilterAdapter method notSupported_inInterleave_inChain.

@Test
public void notSupported_inInterleave_inChain() {
    QualifierFilter qualifierFilter = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("x")));
    WhileMatchFilter whileMatchFilter = new WhileMatchFilter(qualifierFilter);
    FilterList interleaveList = new FilterList(Operator.MUST_PASS_ONE, whileMatchFilter);
    FilterList chainList = new FilterList(Operator.MUST_PASS_ALL, interleaveList);
    Scan scan = new Scan();
    scan.setFilter(chainList);
    FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
    assertFalse(instance.isFilterSupported(context, whileMatchFilter).isSupported());
}
Also used : WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) Scan(org.apache.hadoop.hbase.client.Scan) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) Test(org.junit.Test)

Example 15 with DefaultReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks in project java-bigtable-hbase by googleapis.

the class TestWhileMatchFilterAdapter method wrappedFilterSupported.

@Test
public void wrappedFilterSupported() {
    WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(30));
    Scan scan = new Scan();
    scan.setFilter(filter);
    FilterAdapterContext context = new FilterAdapterContext(scan, new DefaultReadHooks());
    assertEquals(FilterSupportStatus.SUPPORTED, instance.isFilterSupported(context, filter));
}
Also used : WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) Scan(org.apache.hadoop.hbase.client.Scan) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Test(org.junit.Test)

Aggregations

DefaultReadHooks (com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)15 Scan (org.apache.hadoop.hbase.client.Scan)13 Test (org.junit.Test)13 FilterList (org.apache.hadoop.hbase.filter.FilterList)9 PageFilter (org.apache.hadoop.hbase.filter.PageFilter)8 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)6 WhileMatchFilter (org.apache.hadoop.hbase.filter.WhileMatchFilter)6 QualifierFilter (org.apache.hadoop.hbase.filter.QualifierFilter)5 ContextCloseable (com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable)4 Query (com.google.cloud.bigtable.data.v2.models.Query)3 ReadHooks (com.google.cloud.bigtable.hbase.adapters.read.ReadHooks)3 ValueFilter (org.apache.hadoop.hbase.filter.ValueFilter)2 RequestContext (com.google.cloud.bigtable.data.v2.internal.RequestContext)1 Filters (com.google.cloud.bigtable.data.v2.models.Filters)1 Cell (org.apache.hadoop.hbase.Cell)1 Filter (org.apache.hadoop.hbase.filter.Filter)1 FilterBase (org.apache.hadoop.hbase.filter.FilterBase)1 PrefixFilter (org.apache.hadoop.hbase.filter.PrefixFilter)1