public boolean isSingleValue() { return low.getBound() == Marker.Bound.EXACTLY && low.equals(high); }
public String toString(ConnectorSession session) { StringBuilder buffer = new StringBuilder(); if (isSingleValue()) { buffer.append('[').append(low.getPrintableValue(session)).append(']'); } else { buffer.append((low.getBound() == Marker.Bound.EXACTLY) ? '[' : '('); buffer.append(low.isLowerUnbounded() ? "<min>" : low.getPrintableValue(session)); buffer.append(", "); buffer.append(high.isUpperUnbounded() ? "<max>" : high.getPrintableValue(session)); buffer.append((high.getBound() == Marker.Bound.EXACTLY) ? ']' : ')'); } return buffer.toString(); } }
@JsonCreator public Range( @JsonProperty("low") Marker low, @JsonProperty("high") Marker high) { requireNonNull(low, "value is null"); requireNonNull(high, "value is null"); if (!low.getType().equals(high.getType())) { throw new IllegalArgumentException(String.format("Marker types do not match: %s vs %s", low.getType(), high.getType())); } if (low.getBound() == Marker.Bound.BELOW) { throw new IllegalArgumentException("low bound must be EXACTLY or ABOVE"); } if (high.getBound() == Marker.Bound.ABOVE) { throw new IllegalArgumentException("high bound must be EXACTLY or BELOW"); } if (low.compareTo(high) > 0) { throw new IllegalArgumentException("low must be less than or equal to high"); } this.low = low; this.high = high; }
public static PrestoThriftMarker fromMarker(Marker marker) { PrestoThriftBlock value = marker.getValueBlock().isPresent() ? fromBlock(marker.getValueBlock().get(), marker.getType()) : null; return new PrestoThriftMarker(value, fromBound(marker.getBound())); } }
private static OptionalInt extractUpperBound(TupleDomain<Symbol> tupleDomain, Symbol symbol) { if (tupleDomain.isNone()) { return OptionalInt.empty(); } Domain rowNumberDomain = tupleDomain.getDomains().get().get(symbol); if (rowNumberDomain == null) { return OptionalInt.empty(); } ValueSet values = rowNumberDomain.getValues(); if (values.isAll() || values.isNone() || values.getRanges().getRangeCount() <= 0) { return OptionalInt.empty(); } Range span = values.getRanges().getSpan(); if (span.getHigh().isUpperUnbounded()) { return OptionalInt.empty(); } verify(rowNumberDomain.getType().equals(BIGINT)); long upperBound = (Long) span.getHigh().getValue(); if (span.getHigh().getBound() == BELOW) { upperBound--; } if (upperBound > 0 && upperBound <= Integer.MAX_VALUE) { return OptionalInt.of(toIntExact(upperBound)); } return OptionalInt.empty(); }
switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(toPredicate(">", range.getLow().getValue(), type, position)); throw new IllegalArgumentException("Low marker should never use BELOW bound"); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case ABOVE: throw new IllegalArgumentException("High marker should never use ABOVE bound"); break; default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
List<String> rangeConjuncts = new ArrayList<>(); if (!range.getLow().isLowerUnbounded()) { switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(toPredicate(columnName, ">", range.getLow().getValue(), type, accumulator)); throw new IllegalArgumentException("Low marker should never use BELOW bound"); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case ABOVE: throw new IllegalArgumentException("High marker should never use ABOVE bound"); break; default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(new ComparisonExpression(GREATER_THAN, reference, literalEncoder.toExpression(range.getLow().getValue(), type))); throw new IllegalStateException("Low Marker should never use BELOW bound: " + range); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case ABOVE: throw new IllegalStateException("High Marker should never use ABOVE bound: " + range); break; default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
Document rangeConjuncts = new Document(); if (!range.getLow().isLowerUnbounded()) { switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.put(GT_OP, translateValue(range.getLow().getValue(), type)); throw new IllegalArgumentException("Low Marker should never use BELOW bound: " + range); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case ABOVE: throw new IllegalArgumentException("High Marker should never use ABOVE bound: " + range); break; default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(CassandraCqlUtils.validColumnName(columnHandle.getName()) + " > " throw new VerifyException("Low Marker should never use BELOW bound"); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case ABOVE: throw new VerifyException("High Marker should never use ABOVE bound"); break; default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
if (prestoRange.getLow().isLowerUnbounded()) { boolean inclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY; Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(null, false, split, inclusive); boolean inclusive = prestoRange.getLow().getBound() == Bound.EXACTLY; Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue())); accumuloRange = new Range(split, inclusive, null, false); boolean startKeyInclusive = prestoRange.getLow().getBound() == Bound.EXACTLY; Text startSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue())); boolean endKeyInclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY; Text endSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(startSplit, startKeyInclusive, endSplit, endKeyInclusive);
switch (range.getLow().getBound()) { case ABOVE: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).gt(getValue(type, range.getLow().getValue()))); throw new IllegalArgumentException("Low marker should never use BELOW bound"); default: throw new AssertionError("Unhandled bound: " + range.getLow().getBound()); switch (range.getHigh().getBound()) { case EXACTLY: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).lte(getValue(type, range.getHigh().getValue()))); throw new IllegalArgumentException("High marker should never use ABOVE bound"); default: throw new AssertionError("Unhandled bound: " + range.getHigh().getBound());
Marker low = span.getLow(); if (!low.isLowerUnbounded()) { KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.ABOVE) ? KuduPredicate.ComparisonOp.GREATER : KuduPredicate.ComparisonOp.GREATER_EQUAL; KuduPredicate predicate = createComparisonPredicate(columnSchema, op, low.getValue()); KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.BELOW) ? KuduPredicate.ComparisonOp.LESS : KuduPredicate.ComparisonOp.LESS_EQUAL; KuduPredicate predicate = createComparisonPredicate(columnSchema, op, high.getValue());
public boolean isSingleValue() { return low.getBound() == Marker.Bound.EXACTLY && low.equals(high); }
public String toString(ConnectorSession session) { StringBuilder buffer = new StringBuilder(); if (isSingleValue()) { buffer.append('[').append(low.getPrintableValue(session)).append(']'); } else { buffer.append((low.getBound() == Marker.Bound.EXACTLY) ? '[' : '('); buffer.append(low.isLowerUnbounded() ? "<min>" : low.getPrintableValue(session)); buffer.append(", "); buffer.append(high.isUpperUnbounded() ? "<max>" : high.getPrintableValue(session)); buffer.append((high.getBound() == Marker.Bound.EXACTLY) ? ']' : ')'); } return buffer.toString(); } }
@JsonCreator public Range( @JsonProperty("low") Marker low, @JsonProperty("high") Marker high) { requireNonNull(low, "value is null"); requireNonNull(high, "value is null"); if (!low.getType().equals(high.getType())) { throw new IllegalArgumentException(String.format("Marker types do not match: %s vs %s", low.getType(), high.getType())); } if (low.getBound() == Marker.Bound.BELOW) { throw new IllegalArgumentException("low bound must be EXACTLY or ABOVE"); } if (high.getBound() == Marker.Bound.ABOVE) { throw new IllegalArgumentException("high bound must be EXACTLY or BELOW"); } if (low.compareTo(high) > 0) { throw new IllegalArgumentException("low must be less than or equal to high"); } this.low = low; this.high = high; }