private boolean supportShortCircuit() { // Optimization for lexicographic bounds with no extractionFn => binary search through the index return boundDimFilter.getOrdering().equals(StringComparators.LEXICOGRAPHIC) && extractionFn == null; }
@Override public DruidLongPredicate makeLongPredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return longPredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); }
@Override public DruidFloatPredicate makeFloatPredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return floatPredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); }
@Override public DruidDoublePredicate makeDoublePredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return doublePredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); } };
public static BoundRefKey from(BoundDimFilter filter) { return new BoundRefKey( filter.getDimension(), filter.getExtractionFn(), filter.getOrdering() ); }
@Override public int hashCode() { int result = getDimension().hashCode(); result = 31 * result + (getUpper() != null ? getUpper().hashCode() : 0); result = 31 * result + (getLower() != null ? getLower().hashCode() : 0); result = 31 * result + (isLowerStrict() ? 1 : 0); result = 31 * result + (isUpperStrict() ? 1 : 0); result = 31 * result + (getExtractionFn() != null ? getExtractionFn().hashCode() : 0); result = 31 * result + getOrdering().hashCode(); return result; }
public BoundFilter(final BoundDimFilter boundDimFilter) { this.boundDimFilter = boundDimFilter; this.comparator = boundDimFilter.getOrdering(); this.extractionFn = boundDimFilter.getExtractionFn(); this.longPredicateSupplier = boundDimFilter.getLongPredicateSupplier(); this.floatPredicateSupplier = boundDimFilter.getFloatPredicateSupplier(); this.doublePredicateSupplier = boundDimFilter.getDoublePredicateSupplier(); }
return false; return getOrdering().equals(that.getOrdering());
public static Range<BoundValue> toRange(final BoundDimFilter bound) { final BoundValue upper = bound.getUpper() != null ? new BoundValue(bound.getUpper(), bound.getOrdering()) : null; final BoundValue lower = bound.getLower() != null ? new BoundValue(bound.getLower(), bound.getOrdering()) : null; if (lower == null) { return bound.isUpperStrict() ? Range.lessThan(upper) : Range.atMost(upper); } else if (upper == null) { return bound.isLowerStrict() ? Range.greaterThan(lower) : Range.atLeast(lower); } else { BoundType lowerBoundType = bound.isLowerStrict() ? BoundType.OPEN : BoundType.CLOSED; BoundType upperBoundType = bound.isUpperStrict() ? BoundType.OPEN : BoundType.CLOSED; return Range.range(lower, lowerBoundType, upper, upperBoundType); } }
null, bound.getExtractionFn(), bound.getOrdering() ); } else { null, bound.getExtractionFn(), bound.getOrdering() );
@Override public DimFilter process(DimFilter filter) { if (filter instanceof BoundDimFilter) { final BoundDimFilter bound = (BoundDimFilter) filter; final StringComparator naturalStringComparator = sourceRowSignature.naturalStringComparator( SimpleExtraction.of(bound.getDimension(), bound.getExtractionFn()) ); if (bound.hasUpperBound() && bound.hasLowerBound() && bound.getUpper().equals(bound.getLower()) && !bound.isUpperStrict() && !bound.isLowerStrict() && bound.getOrdering().equals(naturalStringComparator)) { return new SelectorDimFilter( bound.getDimension(), bound.getUpper(), bound.getExtractionFn() ); } else { return filter; } } else { return filter; } } }
private boolean supportShortCircuit() { // Optimization for lexicographic bounds with no extractionFn => binary search through the index return boundDimFilter.getOrdering().equals(StringComparators.LEXICOGRAPHIC) && extractionFn == null; }
@Override public DruidLongPredicate makeLongPredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return longPredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); }
@Override public DruidDoublePredicate makeDoublePredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return doublePredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); } };
@Override public DruidFloatPredicate makeFloatPredicate() { if (extractionFn != null) { return input -> doesMatch(extractionFn.apply(input)); } if (boundDimFilter.getOrdering().equals(StringComparators.NUMERIC)) { return floatPredicateSupplier.get(); } return input -> doesMatch(String.valueOf(input)); }
public static BoundRefKey from(BoundDimFilter filter) { return new BoundRefKey( filter.getDimension(), filter.getExtractionFn(), filter.getOrdering() ); }
@Override public int hashCode() { int result = getDimension().hashCode(); result = 31 * result + (getUpper() != null ? getUpper().hashCode() : 0); result = 31 * result + (getLower() != null ? getLower().hashCode() : 0); result = 31 * result + (isLowerStrict() ? 1 : 0); result = 31 * result + (isUpperStrict() ? 1 : 0); result = 31 * result + (getExtractionFn() != null ? getExtractionFn().hashCode() : 0); result = 31 * result + getOrdering().hashCode(); return result; }
public BoundFilter(final BoundDimFilter boundDimFilter) { this.boundDimFilter = boundDimFilter; this.comparator = boundDimFilter.getOrdering(); this.extractionFn = boundDimFilter.getExtractionFn(); this.longPredicateSupplier = boundDimFilter.getLongPredicateSupplier(); this.floatPredicateSupplier = boundDimFilter.getFloatPredicateSupplier(); this.doublePredicateSupplier = boundDimFilter.getDoublePredicateSupplier(); }
public static Range<BoundValue> toRange(final BoundDimFilter bound) { final BoundValue upper = bound.getUpper() != null ? new BoundValue(bound.getUpper(), bound.getOrdering()) : null; final BoundValue lower = bound.getLower() != null ? new BoundValue(bound.getLower(), bound.getOrdering()) : null; if (lower == null) { return bound.isUpperStrict() ? Range.lessThan(upper) : Range.atMost(upper); } else if (upper == null) { return bound.isLowerStrict() ? Range.greaterThan(lower) : Range.atLeast(lower); } else { return Range.range( lower, bound.isLowerStrict() ? BoundType.OPEN : BoundType.CLOSED, upper, bound.isUpperStrict() ? BoundType.OPEN : BoundType.CLOSED ); } }
@Override public DimFilter process(DimFilter filter) { if (filter instanceof BoundDimFilter) { final BoundDimFilter bound = (BoundDimFilter) filter; final StringComparator naturalStringComparator = sourceRowSignature.naturalStringComparator( SimpleExtraction.of(bound.getDimension(), bound.getExtractionFn()) ); if (bound.hasUpperBound() && bound.hasLowerBound() && bound.getUpper().equals(bound.getLower()) && !bound.isUpperStrict() && !bound.isLowerStrict() && bound.getOrdering().equals(naturalStringComparator)) { return new SelectorDimFilter( bound.getDimension(), bound.getUpper(), bound.getExtractionFn() ); } else { return filter; } } else { return filter; } } }