for (Bound b : Bound.values()) if (slice.hasBound(b)) ByteBuffer value = validateIndexedValue(def, slice.bound(b, options)); Operator op = slice.getIndexOperator(b);
Operator relType = ((Restriction.Slice)r).getRelation(eocBound, b); return Collections.singletonList(builder.build().withEOC(eocForRelation(relType)));
if (!cfm.comparator.isCompound() && (!slice.isInclusive(Bound.START) || !slice.isInclusive(Bound.END))) stmt.sliceRestriction = slice;
else if (!existingRestriction.isMultiColumn()) restriction.setBound(existingRestriction); restriction.setBound(relation.operator(), t);
/** * Checks that the operator for the specified column is compatible with the bounds of the existing restriction. * * @param existing the existing restriction * @param def the column definition * @param operator the operator * @throws InvalidRequestException if the operator is not compatible with the bounds of the existing restriction */ private static void checkBound(Restriction existing, ColumnDefinition def, Operator operator) throws InvalidRequestException { Restriction.Slice existingSlice = (Restriction.Slice) existing; if (existingSlice.hasBound(Bound.START) && (operator == Operator.GT || operator == Operator.GTE)) throw new InvalidRequestException(String.format( "More than one restriction was found for the start bound on %s", def.name)); if (existingSlice.hasBound(Bound.END) && (operator == Operator.LT || operator == Operator.LTE)) throw new InvalidRequestException(String.format( "More than one restriction was found for the end bound on %s", def.name)); }
private static boolean isNullRestriction(Restriction r, Bound b) { return r == null || (r.isSlice() && !((Restriction.Slice)r).hasBound(b)); }
private static ByteBuffer getSliceValue(Restriction r, Bound b, QueryOptions options) throws InvalidRequestException { Restriction.Slice slice = (Restriction.Slice)r; assert slice.hasBound(b); ByteBuffer val = slice.bound(b, options); if (val == null) throw new InvalidRequestException(String.format("Invalid null clustering key part %s", r)); return val; }
private int updateLimitForQuery(int limit) { // Internally, we don't support exclusive bounds for slices. Instead, we query one more element if necessary // and exclude it later (in processColumnFamily) return sliceRestriction != null && (!sliceRestriction.isInclusive(Bound.START) || !sliceRestriction.isInclusive(Bound.END)) && limit != Integer.MAX_VALUE ? limit + 1 : limit; }
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)); }
private CellName makeExclusiveSliceBound(Bound bound, CellNameType type, QueryOptions options) throws InvalidRequestException { if (sliceRestriction.isInclusive(bound)) return null; // We can only reach that point if cfm.comparator.isCompound() = false and the table has some clustering columns. // By consequence, we know that the table is a COMPACT table with only one clustering column. ByteBuffer value = sliceRestriction.isMultiColumn() ? ((MultiColumnRestriction.Slice) sliceRestriction).componentBounds(bound, options).get(0) : sliceRestriction.bound(bound, options); // Dense non-compound tables do not accept empty ByteBuffers. By consequence, if the slice value is empty // we know that we can treat the slice as inclusive. return value.hasRemaining() ? type.makeCellName(value) : null; }