SingleColumnValueFilterAdapter extends TypedFilterAdapterBase<SingleColumnValueFilter> { @Override public Filter adapt(FilterAdapterContext context, SingleColumnValueFilter filter) throws IOException { return toFilter(context, filter); } SingleColumnValueFilterAdapter(ValueFilterAdapter delegateAdapter); @Override Filter adapt(FilterAdapterContext context, SingleColumnValueFilter filter); @Override FilterSupportStatus isFilterSupported(
      FilterAdapterContext context, SingleColumnValueFilter filter);  }
@Test public void latestVersionOnlyComparisonsAreDone() throws IOException { byte[] filterValue = Bytes.toBytes("foobar"); byte[] qualifier = Bytes.toBytes("someColumn"); byte[] family = Bytes.toBytes("f"); SingleColumnValueFilter filter = new SingleColumnValueFilter( family, qualifier, CompareFilter.CompareOp.EQUAL, new BinaryComparator(filterValue)); filter.setFilterIfMissing(false); filter.setLatestVersionOnly(true); Filters.Filter adaptedFilter = UNDER_TEST.adapt(new FilterAdapterContext(new Scan(), null), filter); assertFilterIfNotMIssingMatches(family, qualifier, filterValue, true, adaptedFilter); }
@Test public void allVersionComparisonAreDone() throws IOException { byte[] filterValue = Bytes.toBytes("foobar"); byte[] qualifier = Bytes.toBytes("someColumn"); byte[] family = Bytes.toBytes("f"); SingleColumnValueFilter filter = new SingleColumnValueFilter( family, qualifier, CompareFilter.CompareOp.EQUAL, new BinaryComparator(filterValue)); filter.setFilterIfMissing(false); filter.setLatestVersionOnly(false); Filters.Filter adaptedFilter = UNDER_TEST.adapt(new FilterAdapterContext(new Scan(), null), filter); assertFilterIfNotMIssingMatches(family, qualifier, filterValue, false, adaptedFilter); }
@Test public void filterIfMissingIsApplied() throws IOException { String valueStr = "foobar"; byte[] filterValue = Bytes.toBytes(valueStr); byte[] qualifier = Bytes.toBytes("someColumn"); byte[] family = Bytes.toBytes("f"); SingleColumnValueFilter filter = new SingleColumnValueFilter( family, qualifier, CompareFilter.CompareOp.EQUAL, new BinaryComparator(filterValue)); filter.setFilterIfMissing(true); filter.setLatestVersionOnly(false); Filters.Filter adaptedFilter = UNDER_TEST.adapt(new FilterAdapterContext(new Scan(), null), filter); assertColumnSpecification( family, qualifier, false, adaptedFilter.toProto().getCondition().getPredicateFilter()); Assert.assertEquals( createValueRangeFilter(valueStr), getValueRangeFilter( adaptedFilter.toProto().getCondition().getPredicateFilter().getChain())); Assert.assertEquals( FILTERS.pass().toProto(), adaptedFilter.toProto().getCondition().getTrueFilter()); }