"PRIMARY KEY column \"%s\" cannot be restricted (preceding column \"%s\" is not restricted)", cdef.name, previous.name)); if (previousRestriction.isMultiColumn() && previousRestriction.isIN()) throw new InvalidRequestException(String.format( "PRIMARY KEY column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by an IN tuple notation)", cdef.name, previous.name)); else if (restriction.isSlice()) stmt.sliceRestriction = slice; else if (restriction.isIN()) if (!restriction.isMultiColumn() && i != stmt.columnRestrictions.length - 1) throw new InvalidRequestException(String.format("Clustering column \"%s\" cannot be restricted by an IN relation", cdef.name)); throw new InvalidRequestException(String.format("Cannot restrict column \"%s\" by IN relation as a collection is selected by the query", cdef.name)); if (restriction.isMultiColumn()) canRestrictFurtherComponents = false; else if (restriction.isContains())
if (restriction.isEQ()) for (ByteBuffer value : restriction.values(options)) else if (restriction.isSlice() && ((Slice) restriction).hasBound(Bound.END)) ByteBuffer value = restriction.isMultiColumn() ? ((MultiColumnRestriction.Slice) restriction).componentBounds(Bound.END, options).get(0) : ((Slice) restriction).bound(Bound.END, options);
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; }
if (isNullRestriction(r, b) || !r.canEvaluateWithSlices()) return Collections.singletonList(eocBound == Bound.END ? prefix.end() : prefix.start()); if (r.isSlice()) if (r.isMultiColumn()) if (r.isIN()) if (r.isMultiColumn()) List<ByteBuffer> values = r.values(options); if (values.size() != 1) List<ByteBuffer> values = r.values(options); if (r.isMultiColumn())
if (restriction.isSlice()) else if (restriction.isContains()) if (restriction.isMultiColumn()) List<ByteBuffer> values = restriction.values(options); value = values.get(def.position()); List<ByteBuffer> values = restriction.values(options); if (values.size() != 1) throw new InvalidRequestException("IN restrictions are not supported on indexed columns");
else if (!existingRestriction.isSlice()) throw new InvalidRequestException(String.format("Column \"%s\" cannot be restricted by both an equality and an inequality relation", def.name)); else if (existingRestriction.isOnToken() != newRel.onToken) else if (!existingRestriction.isContains()) throw new InvalidRequestException(String.format("Collection column %s can only be restricted by CONTAINS or CONTAINS KEY", def.name));
break; if (!(indexed && stmt.usesSecondaryIndexing) && restriction.canEvaluateWithSlices()) if (restriction.isSlice()) lastSliceRestriction = restriction;
private static boolean isNullRestriction(Restriction r, Bound b) { return r == null || (r.isSlice() && !((Restriction.Slice)r).hasBound(b)); }
private Composite createClusteringPrefixBuilderInternal(QueryOptions options) throws InvalidRequestException { CBuilder builder = cfm.comparator.prefixBuilder(); ColumnDefinition firstEmptyKey = null; for (ColumnDefinition def : cfm.clusteringColumns()) { Restriction r = processedKeys.get(def.name); if (r == null) { firstEmptyKey = def; if (requireFullClusteringKey() && !cfm.comparator.isDense() && cfm.comparator.isCompound()) throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", def.name)); } else if (firstEmptyKey != null) { throw new InvalidRequestException(String.format("Missing PRIMARY KEY part %s since %s is set", firstEmptyKey.name, def.name)); } else { List<ByteBuffer> values = r.values(options); assert values.size() == 1; // We only allow IN for row keys so far ByteBuffer val = values.get(0); if (val == null) throw new InvalidRequestException(String.format("Invalid null value for clustering key part %s", def.name)); builder.add(val); } } return builder.build(); }
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); }
if (r.isIN() && !((Restriction.IN)r).canHaveOnlyOneValue())
private boolean isColumnRange() { // Due to CASSANDRA-5762, we always do a slice for CQL3 tables (not dense, composite). // Static CF (non dense but non composite) never entails a column slice however if (!cfm.comparator.isDense()) return cfm.comparator.isCompound(); // Otherwise (i.e. for compact table where we don't have a row marker anyway and thus don't care about CASSANDRA-5762), // it is a range query if it has at least one the column alias for which no relation is defined or is not EQ. for (Restriction r : columnRestrictions) { if (r == null || r.isSlice()) return true; } return false; }
throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", def.name)); List<ByteBuffer> values = r.values(options);
assert r != null && !r.isSlice(); if (r.isEQ()) List<ByteBuffer> values = r.values(options); if (r.isMultiColumn()) ByteBuffer val = r.values(options).get(0); if (val == null) throw new InvalidRequestException(String.format("Invalid null value for clustering key part %s", def.name)); if (!r.isMultiColumn()) List<ByteBuffer> values = r.values(options);
def.name, operator)); else if (!existing.isSlice())