WhileMatchFilterAdapter extends TypedFilterAdapterBase<WhileMatchFilter> { @Override public FilterSupportStatus isFilterSupported( FilterAdapterContext context, WhileMatchFilter filter) { List<FilterSupportStatus> unsupportedStatuses = new ArrayList<>(); subFilterAdapter.collectUnsupportedStatuses(context, filter.getFilter(), unsupportedStatuses); if (!unsupportedStatuses.isEmpty()) { return FilterSupportStatus.newCompositeNotSupported(unsupportedStatuses); } if (inInterleave(context.getScan().getFilter(), filter)) { return FilterSupportStatus.newNotSupported( "A WhileMatchFilter cannot be in a FilterList with MUST_PASS_ONE operation."); } return FilterSupportStatus.SUPPORTED; } WhileMatchFilterAdapter(FilterAdapter subFilterAdapter); @Override Filters.Filter adapt(FilterAdapterContext context, WhileMatchFilter filter); @Override FilterSupportStatus isFilterSupported(
      FilterAdapterContext context, WhileMatchFilter filter);  }
@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)); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }