public Object getSingleValue() { if (!isSingleValue()) { throw new IllegalStateException("Range does not have just a single value"); } return low.getValue(); }
private FormattedMarker formatMarker(Marker marker) { if (!marker.getValueBlock().isPresent()) { return new FormattedMarker(Optional.empty(), marker.getBound()); } return new FormattedMarker(Optional.of(getVarcharValue(marker.getType(), marker.getValue())), 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(); }
checkState(!range.isAll()); if (range.isSingleValue()) { singleValues.add(range.getLow().getValue()); continue; switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(toPredicate(">", range.getLow().getValue(), type, position)); break; case EXACTLY: rangeConjuncts.add(toPredicate(">=", range.getLow().getValue(), type, position)); break; case BELOW: throw new IllegalArgumentException("High marker should never use ABOVE bound"); case EXACTLY: rangeConjuncts.add(toPredicate("<=", range.getHigh().getValue(), type, position)); break; case BELOW: rangeConjuncts.add(toPredicate("<", range.getHigh().getValue(), type, position)); break; default:
singleValues.add(range.getLow().getValue()); switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(toPredicate(columnName, ">", range.getLow().getValue(), type, accumulator)); break; case EXACTLY: rangeConjuncts.add(toPredicate(columnName, ">=", range.getLow().getValue(), type, accumulator)); break; case BELOW: throw new IllegalArgumentException("High marker should never use ABOVE bound"); case EXACTLY: rangeConjuncts.add(toPredicate(columnName, "<=", range.getHigh().getValue(), type, accumulator)); break; case BELOW: rangeConjuncts.add(toPredicate(columnName, "<", range.getHigh().getValue(), type, accumulator)); break; default:
return new BetweenPredicate(reference, literalEncoder.toExpression(range.getLow().getValue(), type), literalEncoder.toExpression(range.getHigh().getValue(), type)); switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(new ComparisonExpression(GREATER_THAN, reference, literalEncoder.toExpression(range.getLow().getValue(), type))); break; case EXACTLY: rangeConjuncts.add(new ComparisonExpression(GREATER_THAN_OR_EQUAL, reference, literalEncoder.toExpression(range.getLow().getValue(), type))); break; throw new IllegalStateException("High Marker should never use ABOVE bound: " + range); case EXACTLY: rangeConjuncts.add(new ComparisonExpression(LESS_THAN_OR_EQUAL, reference, literalEncoder.toExpression(range.getHigh().getValue(), type))); break; case BELOW: rangeConjuncts.add(new ComparisonExpression(LESS_THAN, reference, literalEncoder.toExpression(range.getHigh().getValue(), type))); break; default:
switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.put(GT_OP, translateValue(range.getLow().getValue(), type)); break; case EXACTLY: rangeConjuncts.put(GTE_OP, translateValue(range.getLow().getValue(), type)); break; case BELOW: throw new IllegalArgumentException("High Marker should never use ABOVE bound: " + range); case EXACTLY: rangeConjuncts.put(LTE_OP, translateValue(range.getHigh().getValue(), type)); break; case BELOW: rangeConjuncts.put(LT_OP, translateValue(range.getHigh().getValue(), type)); break; default:
case ABOVE: rangeConjuncts.add(CassandraCqlUtils.validColumnName(columnHandle.getName()) + " > " + CassandraCqlUtils.cqlValue(toCQLCompatibleString(range.getLow().getValue()), columnHandle.getCassandraType())); break; case EXACTLY: rangeConjuncts.add(CassandraCqlUtils.validColumnName(columnHandle.getName()) + " >= " + CassandraCqlUtils.cqlValue(toCQLCompatibleString(range.getLow().getValue()), columnHandle.getCassandraType())); break; case EXACTLY: rangeConjuncts.add(CassandraCqlUtils.validColumnName(columnHandle.getName()) + " <= " + CassandraCqlUtils.cqlValue(toCQLCompatibleString(range.getHigh().getValue()), columnHandle.getCassandraType())); break; case BELOW: rangeConjuncts.add(CassandraCqlUtils.validColumnName(columnHandle.getName()) + " < " + CassandraCqlUtils.cqlValue(toCQLCompatibleString(range.getHigh().getValue()), columnHandle.getCassandraType())); break;
checkState(!range.isAll(), "Invalid range for column: " + columnName); if (range.isSingleValue()) { valuesToInclude.add(range.getLow().getValue()); switch (range.getLow().getBound()) { case ABOVE: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).gt(getValue(type, range.getLow().getValue()))); break; case EXACTLY: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).gte(getValue(type, range.getLow().getValue()))); break; case BELOW: switch (range.getHigh().getBound()) { case EXACTLY: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).lte(getValue(type, range.getHigh().getValue()))); break; case BELOW: rangeQueryBuilder.must(new RangeQueryBuilder(columnName).lt(getValue(type, range.getHigh().getValue()))); break; case ABOVE:
Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(null, false, split, inclusive); Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue())); accumuloRange = new Range(split, inclusive, null, false); Text startSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue())); Text endSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(startSplit, startKeyInclusive, endSplit, endKeyInclusive);
KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.ABOVE) ? KuduPredicate.ComparisonOp.GREATER : KuduPredicate.ComparisonOp.GREATER_EQUAL; KuduPredicate predicate = createComparisonPredicate(columnSchema, op, low.getValue()); builder.addPredicate(predicate); KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.BELOW) ? KuduPredicate.ComparisonOp.LESS : KuduPredicate.ComparisonOp.LESS_EQUAL; KuduPredicate predicate = createComparisonPredicate(columnSchema, op, high.getValue()); builder.addPredicate(predicate);
public Object getSingleValue() { if (!isSingleValue()) { throw new IllegalStateException("Range does not have just a single value"); } return low.getValue(); }
public static EthereumBlockRange fromMarkers(Marker low, Marker high) { long startBlock; long endBlock; if (low.isLowerUnbounded()) { startBlock = 1L; } else if (low.getBound() == Marker.Bound.EXACTLY) { startBlock = (long) low.getValue(); } else if (low.getBound() == Marker.Bound.ABOVE) { startBlock = (long) low.getValue() + 1L; } else { throw new IllegalArgumentException("Low bound cannot be BELOW"); } if (high.isUpperUnbounded()) { endBlock = -1L; } else if (high.getBound() == Marker.Bound.EXACTLY) { endBlock = (long) high.getValue(); } else if (high.getBound() == Marker.Bound.BELOW) { endBlock = (long) high.getValue() - 1L; } else { throw new IllegalArgumentException("High bound cannot be ABOVE"); } if (startBlock > endBlock && endBlock != -1L) { throw new IllegalArgumentException("Low bound is greater than high bound"); } return new EthereumBlockRange(startBlock, endBlock); }
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 > Integer.MAX_VALUE) { return OptionalInt.empty(); } return OptionalInt.of(Ints.checkedCast(upperBound)); }
return new BetweenPredicate(reference, toExpression(range.getLow().getValue(), type), toExpression(range.getHigh().getValue(), type)); switch (range.getLow().getBound()) { case ABOVE: rangeConjuncts.add(new ComparisonExpression(GREATER_THAN, reference, toExpression(range.getLow().getValue(), type))); break; case EXACTLY: rangeConjuncts.add(new ComparisonExpression(GREATER_THAN_OR_EQUAL, reference, toExpression(range.getLow().getValue(), type))); break; throw new IllegalStateException("High Marker should never use ABOVE bound: " + range); case EXACTLY: rangeConjuncts.add(new ComparisonExpression(LESS_THAN_OR_EQUAL, reference, toExpression(range.getHigh().getValue(), type))); break; case BELOW: rangeConjuncts.add(new ComparisonExpression(LESS_THAN, reference, toExpression(range.getHigh().getValue(), type))); break; default:
Object value = prestoRange.getHigh().getValue(); hbaseScan.setStopRow(toHbaseBytes(type, value)); Object value = prestoRange.getLow().getValue(); hbaseScan.setStartRow(toHbaseBytes(type, value)); Object startSplit = prestoRange.getLow().getValue(); Object endSplit = prestoRange.getHigh().getValue();
if (prestoRange.getHigh().isUpperUnbounded()) { Object value = prestoRange.getLow().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).gte(EsTypeManager.getTypeValue(type, value))); Object value = prestoRange.getHigh().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).lte(EsTypeManager.getTypeValue(type, value))); Object startSplit = EsTypeManager.getTypeValue(type, prestoRange.getLow().getValue()); Object endSplit = EsTypeManager.getTypeValue(type, prestoRange.getHigh().getValue());
if (prestoRange.getHigh().isUpperUnbounded()) { Object value = prestoRange.getLow().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).gte(EsTypeManager.getTypeValue(type, value))); Object value = prestoRange.getHigh().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).lte(EsTypeManager.getTypeValue(type, value))); Object startSplit = EsTypeManager.getTypeValue(type, prestoRange.getLow().getValue()); Object endSplit = EsTypeManager.getTypeValue(type, prestoRange.getHigh().getValue());
if (prestoRange.getHigh().isUpperUnbounded()) { Object value = prestoRange.getLow().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).gte(EsTypeManager.getTypeValue(type, value))); Object value = prestoRange.getHigh().getValue(); qb.must(QueryBuilders.rangeQuery(columnName).lte(EsTypeManager.getTypeValue(type, value))); Object startSplit = EsTypeManager.getTypeValue(type, prestoRange.getLow().getValue()); Object endSplit = EsTypeManager.getTypeValue(type, prestoRange.getHigh().getValue());