Search in sources :

Example 1 with DefaultReadHooks

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;
}
Also used : 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) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)

Example 2 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.

@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());
}
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 3 with DefaultReadHooks

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());
}
Also used : WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) Scan(org.apache.hadoop.hbase.client.Scan) Cell(org.apache.hadoop.hbase.Cell) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) FilterBase(org.apache.hadoop.hbase.filter.FilterBase) Test(org.junit.Test)

Example 4 with DefaultReadHooks

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());
}
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 5 with DefaultReadHooks

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());
}
Also used : ValueFilter(org.apache.hadoop.hbase.filter.ValueFilter) PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) Filter(org.apache.hadoop.hbase.filter.Filter) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) 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)

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