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)); } }
private static String getFeatureSetKey(Predicate predicate) { if (predicate instanceof FeatureSet) { return ((FeatureSet) predicate).getKey(); } else { Negation negation = (Negation) predicate; return ((FeatureSet) negation.getOperand()).getKey(); } }
public Negation notInSet(String... values) { return new Negation(new FeatureSet(key, values)); } }
public static boolean isValidFeatureConjunctionOperand(Predicate operand) { return operand instanceof Negation && ((Negation) operand).getOperand() instanceof FeatureSet && isValidFeatureConjunctionOperand(((Negation) operand).getOperand()) || operand instanceof FeatureSet && ((FeatureSet) operand).getValues().size() == 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 Negation notInRange(long fromInclusive, long toInclusive) { return new Negation(new FeatureRange(key, fromInclusive, toInclusive)); }
public static Predicate fromBinary(byte[] buf) { return BinaryFormat.decode(buf); }
@Override protected void appendTo(StringBuilder out) { if (operand instanceof FeatureSet) { ((FeatureSet)operand).appendNegatedTo(out); } else { out.append("not ("); operand.appendTo(out); out.append(')'); } }
@Override public RangePartition clone() throws CloneNotSupportedException { return (RangePartition)super.clone(); }
@Override protected void appendTo(StringBuilder out) { appendInAsTo("in", out); }
private boolean isTrue(Predicate predicate) { if (predicate instanceof BooleanPredicate) { return ((BooleanPredicate)predicate).getValue(); } return false; }
@Override public FeatureConjunction clone() throws CloneNotSupportedException { return new FeatureConjunction(operands); }
public static Disjunction or(Predicate... operands) { return new Disjunction(operands); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof RangeEdgePartition)) { return false; } RangeEdgePartition other = (RangeEdgePartition)obj; return super.equals(other) && value == other.value && lowerBound == other.lowerBound && upperBound == other.upperBound; }
public static Conjunction and(Predicate... operands) { return new Conjunction(operands); }
public FeatureSet inSet(String... values) { return new FeatureSet(key, values); }
@Override public BooleanPredicate clone() throws CloneNotSupportedException { return (BooleanPredicate)super.clone(); }
protected void appendNegatedTo(StringBuilder out) { appendInAsTo("not in", out); }
private boolean isFalse(Predicate predicate) { if (predicate instanceof BooleanPredicate) { return !((BooleanPredicate)predicate).getValue(); } return false; }