PrefixFilterAdapter extends TypedFilterAdapterBase<PrefixFilter> { @Override public Filter adapt(FilterAdapterContext context, PrefixFilter filter) throws IOException { ByteString.Output output = ByteString.newOutput(filter.getPrefix().length * 2); ReaderExpressionHelper.writeQuotedRegularExpression(output, filter.getPrefix()); output.write(ReaderExpressionHelper.ALL_QUALIFIERS_BYTES); return FILTERS.key().regex(output.toByteString()); }  @Override Filter adapt(FilterAdapterContext context, PrefixFilter filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, PrefixFilter filter); @Override RangeSet<RowKeyWrapper> getIndexScanHint(PrefixFilter filter);  }
@Test public void testPrefixAddedAsRowRegex() throws IOException { PrefixFilterAdapter adapter = new PrefixFilterAdapter(); String prefix = "Foobar"; PrefixFilter filter = new PrefixFilter(Bytes.toBytes(prefix)); Scan emptyScan = new Scan(); FilterAdapterContext context = new FilterAdapterContext(emptyScan, null); byte[] prefixRegex = Bytes.toBytes(prefix + "\\C*"); Assert.assertEquals( FILTERS.key().regex(ByteString.copyFrom(prefixRegex)).toProto(), adapter.adapt(context, filter).toProto()); }