public HBaseScanSpec parseTree() { HBaseScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec); /* * If RowFilter is THE filter attached to the scan specification, * remove it since its effect is also achieved through startRow and stopRow. */ if (parsedSpec.filter instanceof RowFilter && ((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL && ((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) { parsedSpec.filter = null; } } return parsedSpec; }
@Test public void testRowFilter() throws IOException { String filterString = "RowFilter ( =, 'binary:regionse')"; RowFilter rowFilter = doTestFilter(filterString, RowFilter.class); assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator()); assertTrue(rowFilter.getComparator() instanceof BinaryComparator); BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator(); assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8)); }
@Test public void testWhileFilter() throws IOException { String filterString = " WHILE RowFilter ( !=, 'binary:row1')"; WhileMatchFilter whileMatchFilter = doTestFilter(filterString, WhileMatchFilter.class); assertTrue(whileMatchFilter.getFilter() instanceof RowFilter); RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter(); assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator()); assertTrue(rowFilter.getComparator() instanceof BinaryComparator); BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator(); assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8)); }
public HBaseScanSpec parseTree() { HBaseScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec); /* * If RowFilter is THE filter attached to the scan specification, * remove it since its effect is also achieved through startRow and stopRow. */ Filter filter = parsedSpec.getFilter(); if (filter instanceof RowFilter && ((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL && ((RowFilter)filter).getComparator() instanceof BinaryComparator) { parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null); } } return parsedSpec; }
/** {@inheritDoc} */ @Override public Filter adapt(FilterAdapterContext context, org.apache.hadoop.hbase.filter.RowFilter 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(); ByteString regexValue; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { regexValue = ByteString.copyFrom(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { regexValue = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); } else { throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator .getClass().getCanonicalName())); } return FILTERS.key().regex(regexValue); }
/** {@inheritDoc} */ @Override public Filter adapt(FilterAdapterContext context, org.apache.hadoop.hbase.filter.RowFilter 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(); ByteString regexValue; if (comparator == null) { throw new IllegalStateException("Comparator cannot be null"); } else if (comparator instanceof RegexStringComparator) { regexValue = ByteString.copyFrom(comparator.getValue()); } else if (comparator instanceof BinaryComparator) { regexValue = ReaderExpressionHelper.quoteRegularExpression(comparator.getValue()); } else { throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator .getClass().getCanonicalName())); } return FILTERS.key().regex(regexValue); }
/** {@inheritDoc} */ @Override public FilterSupportStatus isFilterSupported( FilterAdapterContext context, org.apache.hadoop.hbase.filter.RowFilter filter) { ByteArrayComparable comparator = filter.getComparator(); if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) { return FilterSupportStatus.newNotSupported(comparator.getClass().getName() + " comparator is not supported"); } if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) { return FilterSupportStatus.newNotSupported(filter.getOperator() + " operator is not supported"); } return FilterSupportStatus.SUPPORTED; } }
/** {@inheritDoc} */ @Override public FilterSupportStatus isFilterSupported( FilterAdapterContext context, org.apache.hadoop.hbase.filter.RowFilter filter) { ByteArrayComparable comparator = filter.getComparator(); if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) { return FilterSupportStatus.newNotSupported(comparator.getClass().getName() + " comparator is not supported"); } if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) { return FilterSupportStatus.newNotSupported(filter.getOperator() + " operator is not supported"); } return FilterSupportStatus.SUPPORTED; } }
public HBaseScanSpec parseTree() { HBaseScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec); /* * If RowFilter is THE filter attached to the scan specification, * remove it since its effect is also achieved through startRow and stopRow. */ if (parsedSpec.filter instanceof RowFilter && ((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL && ((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) { parsedSpec.filter = null; } } return parsedSpec; }
@Test public void testRowFilter() throws IOException { String filterString = "RowFilter ( =, 'binary:regionse')"; RowFilter rowFilter = doTestFilter(filterString, RowFilter.class); assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator()); assertTrue(rowFilter.getComparator() instanceof BinaryComparator); BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator(); assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8)); }
public HBaseScanSpec parseTree() { HBaseScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec = mergeScanSpecs("booleanAnd", oldSpec, parsedSpec); /* * If RowFilter is THE filter attached to the scan specification, * remove it since its effect is also achieved through startRow and stopRow. */ Filter parsedFilter = HBaseUtils.deserializeFilter(parsedSpec.getSerializedFilter()); if (parsedFilter instanceof RowFilter && ((RowFilter)parsedFilter).getComparator() instanceof BinaryComparator) { return new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), (byte[]) null); } } return parsedSpec; }
@Test public void testWhileFilter() throws IOException { String filterString = " WHILE RowFilter ( !=, 'binary:row1')"; WhileMatchFilter whileMatchFilter = doTestFilter(filterString, WhileMatchFilter.class); assertTrue(whileMatchFilter.getFilter() instanceof RowFilter); RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter(); assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator()); assertTrue(rowFilter.getComparator() instanceof BinaryComparator); BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator(); assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8)); }
public HBaseScanSpec parseTree() { HBaseScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec); /* * If RowFilter is THE filter attached to the scan specification, * remove it since its effect is also achieved through startRow and stopRow. */ Filter filter = parsedSpec.getFilter(); if (filter instanceof RowFilter && ((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL && ((RowFilter)filter).getComparator() instanceof BinaryComparator) { parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null); } } return parsedSpec; }