smiklosovic commented on code in PR #4785:
URL: https://github.com/apache/cassandra/pull/4785#discussion_r3187346068
##########
src/java/org/apache/cassandra/cql3/statements/SelectStatement.java:
##########
@@ -815,11 +814,21 @@ private ReadQuery getSliceCommands(QueryOptions options,
ClientState state, Colu
if (filter == null || filter.isEmpty(table.comparator))
return ReadQuery.empty(table);
- List<DecoratedKey> decoratedKeys = new ArrayList<>(keys.size());
- for (ByteBuffer key : keys)
+ List<DecoratedKey> decoratedKeys;
+ if (keys.size() == 1) // reduce allocations in collections for keys
{
+ ByteBuffer key = keys.get(0);
QueryProcessor.validateKey(key);
-
decoratedKeys.add(table.partitioner.decorateKey(ByteBufferUtil.clone(key)));
+ decoratedKeys =
Collections.singletonList(table.partitioner.decorateKey(key));
+ }
+ else
+ {
+ decoratedKeys = new ArrayList<>(keys.size());
+ for (ByteBuffer key : keys)
+ {
+ QueryProcessor.validateKey(key);
Review Comment:
in case some key is invalid, e.g we have 10 keys and 8th is invalid, then we
would do `table.partitioner.decorateKey(key)` 7 times unnecessarily too,
`decorateKey(key)` allocates quite a lot internally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]