@Test public void testChainedIndexHintIntersection() { FilterAdapter adapter = FilterAdapter.buildAdapter(); PrefixFilter p1 = new PrefixFilter("a".getBytes()); PrefixFilter p2 = new PrefixFilter("abc".getBytes()); FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, p1, p2); RangeSet<RowKeyWrapper> actual = adapter.getIndexScanHint(filterList); RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of( Range.closedOpen( new RowKeyWrapper(ByteString.copyFromUtf8("abc")), new RowKeyWrapper(ByteString.copyFromUtf8("abd")))); Assert.assertEquals(expected, actual); }
@Override public RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter) { final List<RangeSet<RowKeyWrapper>> childHints = collectChildHints(filter); if (childHints.isEmpty()) { return ImmutableRangeSet.of(Range.<RowKeyWrapper>all()); } else if (childHints.size() == 1) { return childHints.get(0); } TreeRangeSet<RowKeyWrapper> result = TreeRangeSet.create(childHints.get(0)); switch (filter.getOperator()) { case MUST_PASS_ONE: for (int i = 1; i < childHints.size(); i++) { result.addAll(childHints.get(i)); } break; case MUST_PASS_ALL: for (int i = 1; i < childHints.size(); i++) { result.removeAll(childHints.get(i).complement()); } break; default: throw new IllegalStateException("Unknown operator: " + filter.getOperator()); } return ImmutableRangeSet.copyOf(result); }
FilterListAdapter extends TypedFilterAdapterBase<FilterList> implements UnsupportedStatusCollector<FilterList> { @Override public RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter) { final List<RangeSet<RowKeyWrapper>> childHints = collectChildHints(filter); if (childHints.isEmpty()) { return ImmutableRangeSet.of(Range.<RowKeyWrapper>all()); } else if (childHints.size() == 1) { return childHints.get(0); } TreeRangeSet<RowKeyWrapper> result = TreeRangeSet.create(childHints.get(0)); switch (filter.getOperator()) { case MUST_PASS_ONE: for (int i = 1; i < childHints.size(); i++) { result.addAll(childHints.get(i)); } break; case MUST_PASS_ALL: for (int i = 1; i < childHints.size(); i++) { result.removeAll(childHints.get(i).complement()); } break; default: throw new IllegalStateException("Unknown operator: " + filter.getOperator()); } return ImmutableRangeSet.copyOf(result); } }
FilterListAdapter extends TypedFilterAdapterBase<FilterList> implements UnsupportedStatusCollector<FilterList> { @Override public RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter) { final List<RangeSet<RowKeyWrapper>> childHints = collectChildHints(filter); if (childHints.isEmpty()) { return ImmutableRangeSet.of(Range.<RowKeyWrapper>all()); } else if (childHints.size() == 1) { return childHints.get(0); } TreeRangeSet<RowKeyWrapper> result = TreeRangeSet.create(childHints.get(0)); switch (filter.getOperator()) { case MUST_PASS_ONE: for (int i = 1; i < childHints.size(); i++) { result.addAll(childHints.get(i)); } break; case MUST_PASS_ALL: for (int i = 1; i < childHints.size(); i++) { result.removeAll(childHints.get(i).complement()); } break; default: throw new IllegalStateException("Unknown operator: " + filter.getOperator()); } return ImmutableRangeSet.copyOf(result); } FilterListAdapter(FilterAdapter subFilterAdapter); }
FilterListAdapter extends TypedFilterAdapterBase<FilterList> implements UnsupportedStatusCollector<FilterList> { @Override public RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter) { final List<RangeSet<RowKeyWrapper>> childHints = collectChildHints(filter); if (childHints.isEmpty()) { return ImmutableRangeSet.of(Range.<RowKeyWrapper>all()); } else if (childHints.size() == 1) { return childHints.get(0); } TreeRangeSet<RowKeyWrapper> result = TreeRangeSet.create(childHints.get(0)); switch (filter.getOperator()) { case MUST_PASS_ONE: for (int i = 1; i < childHints.size(); i++) { result.addAll(childHints.get(i)); } break; case MUST_PASS_ALL: for (int i = 1; i < childHints.size(); i++) { result.removeAll(childHints.get(i).complement()); } break; default: throw new IllegalStateException("Unknown operator: " + filter.getOperator()); } return ImmutableRangeSet.copyOf(result); } FilterListAdapter(FilterAdapter subFilterAdapter); @Override Filters.Filter adapt(FilterAdapterContext context, FilterList filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, FilterList filter); @Override void collectUnsupportedStatuses(
      FilterAdapterContext context,
      FilterList filter,
      List<FilterSupportStatus> unsupportedStatuses); @Override RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter); }
FilterListAdapter extends TypedFilterAdapterBase<FilterList> implements UnsupportedStatusCollector<FilterList> { @Override public RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter) { final List<RangeSet<RowKeyWrapper>> childHints = collectChildHints(filter); if (childHints.isEmpty()) { return ImmutableRangeSet.of(Range.<RowKeyWrapper>all()); } else if (childHints.size() == 1) { return childHints.get(0); } TreeRangeSet<RowKeyWrapper> result = TreeRangeSet.create(childHints.get(0)); switch (filter.getOperator()) { case MUST_PASS_ONE: for (int i = 1; i < childHints.size(); i++) { result.addAll(childHints.get(i)); } break; case MUST_PASS_ALL: for (int i = 1; i < childHints.size(); i++) { result.removeAll(childHints.get(i).complement()); } break; default: throw new IllegalStateException("Unknown operator: " + filter.getOperator()); } return ImmutableRangeSet.copyOf(result); } FilterListAdapter(FilterAdapter subFilterAdapter); @Override Filters.Filter adapt(FilterAdapterContext context, FilterList filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, FilterList filter); @Override void collectUnsupportedStatuses(
      FilterAdapterContext context,
      FilterList filter,
      List<FilterSupportStatus> unsupportedStatuses); @Override RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter);  }