public FeatureRange lessThan(long toExclusive) { return new FeatureRange(key, null, toExclusive - 1); }
private void addEdgePartition(FeatureRange range, long value, int from, int to, boolean isNeg) { String label; if (value == 0x8000000000000000L) // special case long_min. label = range.getKey() + "=-9223372036854775808"; else label = range.getKey() + (isNeg ? "=-" : "=") + Long.toString(value); range.addPartition(new RangeEdgePartition(label, value, from, to)); }
public FeatureRange(String key, Long fromInclusive, Long toInclusive) { setKey(key); setFromInclusive(fromInclusive); setToInclusive(toInclusive); partitions = new ArrayList<>(); edgePartitions = new ArrayList<>(); }
FeatureRange range = (FeatureRange) predicate; out.setLong(NODE_TYPE, TYPE_FEATURE_RANGE); out.setString(KEY, range.getKey()); Long from = range.getFromInclusive(); if (from != null) { out.setLong(RANGE_MIN, from); Long to = range.getToInclusive(); if (to != null) { out.setLong(RANGE_MAX, to); for (RangePartition p : range.getPartitions()) { p_out.addLong(PredicateHash.hash64(p.getLabel())); for (RangeEdgePartition p : range.getEdgePartitions()) { Cursor obj = p_out.addObject(); obj.setLong(HASH, PredicateHash.hash64(p.getLabel()));
FeatureRange featureRange = new FeatureRange(in.field(KEY).asString()); if (in.field(RANGE_MIN).valid()) { featureRange.setFromInclusive(in.field(RANGE_MIN).asLong()); featureRange.setToInclusive(in.field(RANGE_MAX).asLong()); featureRange.addPartition(new RangePartition(p_in.entry(i).asString())); featureRange.addPartition(new RangeEdgePartition( obj.field(LABEL).asString(), obj.field(VALUE).asLong(), (int)obj.field(LOWER_BOUND).asLong(), (int)obj.field(UPPER_BOUND).asLong()));
r = new FeatureRange(key); r.setFromInclusive(Long.parseLong(i1.getText())); r.setToInclusive(Long.parseLong(i2.getText()));
public RangePruner(FeatureRange range, PredicateOptions options, int arity) { from = range.getFromInclusive() != null ? range.getFromInclusive() : options.getAdjustedLowerBound(); to = range.getToInclusive() != null ? range.getToInclusive() : options.getAdjustedUpperBound(); if (from > options.getUpperBound()) { // Range completely beyond bounds long upperRangeStart = Long.MAX_VALUE - (Long.MAX_VALUE % arity) - arity; if (options.getUpperBound() < upperRangeStart) { from = upperRangeStart; to = upperRangeStart + arity - 1; } else { to = from; } } else if (to < options.getLowerBound()) { // Range completely before bounds long lowerRangeEnd = Long.MIN_VALUE + (arity - (Long.MIN_VALUE % arity)); if (options.getLowerBound() > lowerRangeEnd) { from = lowerRangeEnd - arity + 1; to = lowerRangeEnd; } else { from = to; } } else { // Modify if range overlaps bounds if (from < options.getLowerBound()) { from = options.getAdjustedLowerBound(); } if (to > options.getUpperBound()) { to = options.getAdjustedUpperBound(); } } }
@Override protected void appendTo(StringBuilder out) { appendQuotedTo(key, out); out.append(" in ["); if (from != null) { out.append(from); } out.append(".."); if (to != null) { out.append(to); } if (!partitions.isEmpty() || !edgePartitions.isEmpty()) { out.append(" ("); for (RangeEdgePartition p : edgePartitions) { p.appendTo(out); out.append(','); } for (RangePartition p : partitions) { p.appendTo(out); out.append(','); } out.deleteCharAt(out.length() - 1); // Remove extra ',' out.append(")"); } out.append("]"); }
private void processFeatureRange(FeatureRange range, PredicateOptions options) { range.clearPartitions(); int arity = options.getArity(); RangePruner rangePruner = new RangePruner(range, options, arity); long from = rangePruner.getFrom(); long to = rangePruner.getTo(); if (from < 0) { if (to < 0) { // Special case for to==-1. -X-0 means the same as -X-1, but is more efficient. partitionRange(range, (to == -1 ? 0 : -to), -from, arity, true); } else { partitionRange(range, 0, -from, arity, true); partitionRange(range, 0, to, arity, false); } } else { partitionRange(range, from, to, arity, false); } }
private void addPartitions(FeatureRange range, long part, long partSize, int first, int last, boolean isNeg) { for (int i = first; i < last; ++i) { range.addPartition(new RangePartition( range.getKey(), (part + i) * partSize, (part + i + 1) * partSize - 1, isNeg)); } }
public FeatureRange lessThanOrEqualTo(long toInclusive) { return new FeatureRange(key, null, toInclusive); }
public FeatureRange inRange(long fromInclusive, long toInclusive) { return new FeatureRange(key, fromInclusive, toInclusive); }
public FeatureRange greaterThan(long fromExclusive) { return new FeatureRange(key, fromExclusive + 1, null); }
public FeatureRange greaterThanOrEqualTo(long fromInclusive) { return new FeatureRange(key, fromInclusive, null); }
public Negation notInRange(long fromInclusive, long toInclusive) { return new Negation(new FeatureRange(key, fromInclusive, toInclusive)); }
return new FeatureRange(key, fromInclusive, toInclusive);