private List<ReadCommand> getSliceCommands(QueryOptions options, int limit, long now) throws RequestValidationException { Collection<ByteBuffer> keys = getKeys(options); if (keys.isEmpty()) // in case of IN () for (the last column of) the partition key. return null; List<ReadCommand> commands = new ArrayList<>(keys.size()); IDiskAtomFilter filter = makeFilter(options, limit); if (filter == null) return null; // Note that we use the total limit for every key, which is potentially inefficient. // However, IN + LIMIT is not a very sensible choice. for (ByteBuffer key : keys) { QueryProcessor.validateKey(key); // We should not share the slice filter amongst the commands (hence the cloneShallow), due to // SliceQueryFilter not being immutable due to its columnCounter used by the lastCounted() method // (this is fairly ugly and we should change that but that's probably not a tiny refactor to do that cleanly) commands.add(ReadCommand.create(keyspace(), ByteBufferUtil.clone(key), columnFamily(), now, filter.cloneShallow())); } return commands; }
private RangeSliceCommand getRangeCommand(QueryOptions options, int limit, long now) throws RequestValidationException { IDiskAtomFilter filter = makeFilter(options, limit); if (filter == null) return null; List<IndexExpression> expressions = getValidatedIndexExpressions(options); // The LIMIT provided by the user is the number of CQL row he wants returned. // We want to have getRangeSlice to count the number of columns, not the number of keys. AbstractBounds<RowPosition> keyBounds = getKeyBounds(options); return keyBounds == null ? null : new RangeSliceCommand(keyspace(), columnFamily(), now, filter, keyBounds, expressions, limit, !parameters.isDistinct, false); }