@Test public void testAdapt_EmptyRegex() throws IOException { String regexp = ""; RegexStringComparator comparator = new RegexStringComparator(regexp); org.apache.hadoop.hbase.filter.RowFilter filter = new org.apache.hadoop.hbase.filter.RowFilter(CompareFilter.CompareOp.EQUAL, comparator); Assert.assertEquals( RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFrom(regexp.getBytes())).build(), adapter.adapt(context, filter).toProto()); }
@Override public Filter adapt(FilterAdapterContext context, FamilyFilter filter) throws IOException { CompareOp compareOp = filter.getOperator(); if (compareOp != CompareFilter.CompareOp.EQUAL) { throw new IllegalStateException( String.format( "Cannot adapt operator %s", compareOp == null ? null : compareOp.getClass().getCanonicalName())); } ByteArrayComparable comparator = filter.getComparator(); String family = null; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { family = Bytes.toString(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { ByteString quotedRegularExpression = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); family = quotedRegularExpression.toStringUtf8(); } else { throw new IllegalStateException( "Cannot adapt comparator " + comparator.getClass().getCanonicalName()); } return FILTERS.family().regex(family); }
FamilyFilterAdapter extends TypedFilterAdapterBase<FamilyFilter> { @Override public Filter adapt(FilterAdapterContext context, FamilyFilter filter) throws IOException { CompareOp compareOp = filter.getOperator(); if (compareOp != CompareFilter.CompareOp.EQUAL) { throw new IllegalStateException( String.format( "Cannot adapt operator %s", compareOp == null ? null : compareOp.getClass().getCanonicalName())); } ByteArrayComparable comparator = filter.getComparator(); String family = null; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { family = Bytes.toString(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { ByteString quotedRegularExpression = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); family = quotedRegularExpression.toStringUtf8(); } else { throw new IllegalStateException( "Cannot adapt comparator " + comparator.getClass().getCanonicalName()); } return FILTERS.family().regex(family); } }
FamilyFilterAdapter extends TypedFilterAdapterBase<FamilyFilter> { @Override public Filter adapt(FilterAdapterContext context, FamilyFilter filter) throws IOException { CompareOp compareOp = filter.getOperator(); if (compareOp != CompareFilter.CompareOp.EQUAL) { throw new IllegalStateException( String.format( "Cannot adapt operator %s", compareOp == null ? null : compareOp.getClass().getCanonicalName())); } ByteArrayComparable comparator = filter.getComparator(); String family = null; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { family = Bytes.toString(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { ByteString quotedRegularExpression = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); family = quotedRegularExpression.toStringUtf8(); } else { throw new IllegalStateException( "Cannot adapt comparator " + comparator.getClass().getCanonicalName()); } return FILTERS.family().regex(family); }  }
FamilyFilterAdapter extends TypedFilterAdapterBase<FamilyFilter> { @Override public Filter adapt(FilterAdapterContext context, FamilyFilter filter) throws IOException { CompareOp compareOp = filter.getOperator(); if (compareOp != CompareFilter.CompareOp.EQUAL) { throw new IllegalStateException( String.format( "Cannot adapt operator %s", compareOp == null ? null : compareOp.getClass().getCanonicalName())); } ByteArrayComparable comparator = filter.getComparator(); String family = null; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { family = Bytes.toString(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { ByteString quotedRegularExpression = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); family = quotedRegularExpression.toStringUtf8(); } else { throw new IllegalStateException( "Cannot adapt comparator " + comparator.getClass().getCanonicalName()); } return FILTERS.family().regex(family); }  @Override Filter adapt(FilterAdapterContext context, FamilyFilter filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, FamilyFilter filter); }
FamilyFilterAdapter extends TypedFilterAdapterBase<FamilyFilter> { @Override public Filter adapt(FilterAdapterContext context, FamilyFilter filter) throws IOException { CompareOp compareOp = filter.getOperator(); if (compareOp != CompareFilter.CompareOp.EQUAL) { throw new IllegalStateException( String.format( "Cannot adapt operator %s", compareOp == null ? null : compareOp.getClass().getCanonicalName())); } ByteArrayComparable comparator = filter.getComparator(); String family = null; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { family = Bytes.toString(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { ByteString quotedRegularExpression = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); family = quotedRegularExpression.toStringUtf8(); } else { throw new IllegalStateException( "Cannot adapt comparator " + comparator.getClass().getCanonicalName()); } return FILTERS.family().regex(family); }  @Override Filter adapt(FilterAdapterContext context, FamilyFilter filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, FamilyFilter filter);  }