@Override public final void setBound(Operator operator, Term t) throws InvalidRequestException { Bound b; boolean inclusive; switch (operator) { case GT: b = Bound.START; inclusive = false; break; case GTE: b = Bound.START; inclusive = true; break; case LT: b = Bound.END; inclusive = false; break; case LTE: b = Bound.END; inclusive = true; break; default: throw new AssertionError(); } setBound(b, inclusive, t); }
existingRestriction = new SingleColumnRestriction.Slice(newRel.onToken); else if (!existingRestriction.isSlice()) throw new InvalidRequestException(String.format("Column \"%s\" cannot be restricted by both an equality and an inequality relation", def.name)); ((SingleColumnRestriction.Slice) existingRestriction).setBound(newRel.operator(), t);
private Token getTokenBound(Bound b, QueryOptions options, IPartitioner p) throws InvalidRequestException { assert onToken; Restriction restriction = keyRestrictions[0]; assert !restriction.isMultiColumn() : "Unexpectedly got a multi-column restriction on a partition key for a range query"; SingleColumnRestriction keyRestriction = (SingleColumnRestriction)restriction; ByteBuffer value; if (keyRestriction.isEQ()) { value = keyRestriction.values(options).get(0); } else { SingleColumnRestriction.Slice slice = (SingleColumnRestriction.Slice)keyRestriction; if (!slice.hasBound(b)) return p.getMinimumToken(); value = slice.bound(b, options); } if (value == null) throw new InvalidRequestException("Invalid null token value"); return p.getTokenFactory().fromByteArray(value); }
private boolean includeKeyBound(Bound b) { for (Restriction r : keyRestrictions) { if (r == null) return true; else if (r.isSlice()) { assert !r.isMultiColumn() : "Unexpectedly got multi-column restriction on partition key"; return ((SingleColumnRestriction.Slice)r).isInclusive(b); } } // All equality return true; }
public void setBound(Restriction.Slice slice) throws InvalidRequestException { for (Bound bound : Bound.values()) if (slice.hasBound(bound)) setBound(bound, slice.isInclusive(bound), slice.bound(bound)); }