ColumnRangeFilterAdapter extends TypedFilterAdapterBase<ColumnRangeFilter> { @Override public Filter adapt(FilterAdapterContext context, ColumnRangeFilter filter) throws IOException { byte[] familyName = getSingleFamily(context.getScan()); QualifierRangeFilter rangeBuilder = FILTERS.qualifier().rangeWithinFamily(Bytes.toString(familyName)); if (filter.getMinColumn() != null) { ByteString startQualifier = ByteString.copyFrom(filter.getMinColumn()); if (filter.getMinColumnInclusive()) { rangeBuilder.startClosed(startQualifier); } else { rangeBuilder.startOpen(startQualifier); } } if (filter.getMaxColumn() != null) { ByteString endQualifier = ByteString.copyFrom(filter.getMaxColumn()); if (filter.getMaxColumnInclusive()) { rangeBuilder.endClosed(endQualifier); } else { rangeBuilder.endOpen(endQualifier); } } return rangeBuilder; }  @Override Filter adapt(FilterAdapterContext context, ColumnRangeFilter filter); @Override FilterSupportStatus isFilterSupported(
      FilterAdapterContext context, ColumnRangeFilter filter);  }
@Test public void testColumnRangeFilterWithASingleFamily_startAndEnd() throws IOException { ColumnRangeFilter filter = new ColumnRangeFilter(Bytes.toBytes("a"), true, Bytes.toBytes("b"), false); Scan familyScan = new Scan().addFamily(Bytes.toBytes("foo")); Filters.Filter expected = filterAdapter.adapt(new FilterAdapterContext(familyScan, null), filter); ColumnRange columnRange = expected.toProto().getColumnRangeFilter(); Assert.assertEquals(0, columnRange.getStartQualifierOpen().size()); Assert.assertEquals("a", toString(columnRange.getStartQualifierClosed())); Assert.assertEquals("b", toString(columnRange.getEndQualifierOpen())); Assert.assertEquals(0, columnRange.getEndQualifierClosed().size()); }
@Test public void testColumnRangeFilterWithASingleFamily_openStart() throws IOException { ColumnRangeFilter filter = new ColumnRangeFilter(null, true, Bytes.toBytes("b"), false); Scan familyScan = new Scan().addFamily(Bytes.toBytes("foo")); Filters.Filter expectedFilter = filterAdapter.adapt(new FilterAdapterContext(familyScan, null), filter); ColumnRange columnRange = expectedFilter.toProto().getColumnRangeFilter(); Assert.assertEquals(0, columnRange.getStartQualifierClosed().size()); Assert.assertEquals(0, columnRange.getStartQualifierOpen().size()); Assert.assertEquals("b", toString(columnRange.getEndQualifierOpen())); Assert.assertEquals(0, columnRange.getEndQualifierClosed().size()); }
@Test public void testColumnRangeFilterWithASingleFamily_openEnd() throws IOException { ColumnRangeFilter filter = new ColumnRangeFilter(Bytes.toBytes("a"), true, null, false); Scan familyScan = new Scan().addFamily(Bytes.toBytes("foo")); Filters.Filter expectedFilter = filterAdapter.adapt(new FilterAdapterContext(familyScan, null), filter); ColumnRange columnRange = expectedFilter.toProto().getColumnRangeFilter(); Assert.assertEquals("a", toString(columnRange.getStartQualifierClosed())); Assert.assertEquals(0, columnRange.getStartQualifierOpen().size()); Assert.assertEquals(0, columnRange.getEndQualifierOpen().size()); Assert.assertEquals(0, columnRange.getEndQualifierClosed().size()); }