Search in sources :

Example 1 with ContextCloseable

use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method mustPassOneIsNotSupported.

@Test
public void mustPassOneIsNotSupported() {
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), new DefaultReadHooks());
    PageFilter filter = new PageFilter(20);
    FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, filter);
    try (ContextCloseable ignroed = context.beginFilterList(filterList)) {
        FilterSupportStatus status = pageFilterAdapter.isFilterSupported(context, filter);
        Assert.assertFalse("MUST_PASS_ONE FilterLists should not be supported.", 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 2 with ContextCloseable

use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method mustPassAllIsSupportedAtTopLevel.

@Test
public void mustPassAllIsSupportedAtTopLevel() {
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), new DefaultReadHooks());
    PageFilter filter = new PageFilter(20);
    FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, filter);
    try (ContextCloseable ignored = context.beginFilterList(filterList)) {
        FilterSupportStatus status = pageFilterAdapter.isFilterSupported(context, filter);
        Assert.assertTrue("MUST_PASS_ALL should be supported at the 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 3 with ContextCloseable

use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable in project java-bigtable-hbase by googleapis.

the class TestMultiRowRangeAdapter method testInterleaveIsUnsupported.

@Test
public void testInterleaveIsUnsupported() throws IOException {
    MultiRowRangeFilter rangeFilter = new MultiRowRangeFilter(Arrays.asList(new RowRange("b", true, "b", true)));
    ColumnPrefixFilter colPrefix = new ColumnPrefixFilter("c".getBytes());
    FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, rangeFilter, colPrefix);
    try (ContextCloseable ignored = context.beginFilterList(filterList)) {
        Assert.assertFalse(adapter.isFilterSupported(context, rangeFilter).isSupported());
    }
}
Also used : ColumnPrefixFilter(org.apache.hadoop.hbase.filter.ColumnPrefixFilter) ContextCloseable(com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) MultiRowRangeFilter(org.apache.hadoop.hbase.filter.MultiRowRangeFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) Test(org.junit.Test)

Example 4 with ContextCloseable

use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method pageFilterMustBeInLastPosition.

@Test
public void pageFilterMustBeInLastPosition() {
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), new DefaultReadHooks());
    ValueFilter valueFilter = new ValueFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("value")));
    PageFilter pageFilter = new PageFilter(20);
    FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, pageFilter, valueFilter);
    try (ContextCloseable ignored = context.beginFilterList(filterList)) {
        FilterSupportStatus status = pageFilterAdapter.isFilterSupported(context, pageFilter);
        Assert.assertFalse("PageFilter must be in the last position of a MUST_PASS_ALL filter list", status.isSupported());
    }
}
Also used : ContextCloseable(com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable) Scan(org.apache.hadoop.hbase.client.Scan) ValueFilter(org.apache.hadoop.hbase.filter.ValueFilter) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) Test(org.junit.Test)

Example 5 with ContextCloseable

use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable 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)

Aggregations

ContextCloseable (com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext.ContextCloseable)5 FilterList (org.apache.hadoop.hbase.filter.FilterList)5 Test (org.junit.Test)5 DefaultReadHooks (com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)4 Scan (org.apache.hadoop.hbase.client.Scan)4 PageFilter (org.apache.hadoop.hbase.filter.PageFilter)4 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)1 ColumnPrefixFilter (org.apache.hadoop.hbase.filter.ColumnPrefixFilter)1 MultiRowRangeFilter (org.apache.hadoop.hbase.filter.MultiRowRangeFilter)1 RowRange (org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange)1 ValueFilter (org.apache.hadoop.hbase.filter.ValueFilter)1