You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "maedhroz (via GitHub)" <gi...@apache.org> on 2024/06/11 21:22:31 UTC
[PR] CASSANDRA-19675 Avoid streams in the common case for UpdateTransaction creation [cassandra]
maedhroz opened a new pull request, #3370:
URL: https://github.com/apache/cassandra/pull/3370
patch by Caleb Rackliffe; reviewed by ? for CASSANDRA-19675
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] CASSANDRA-19675 Avoid streams in the common case for UpdateTransaction creation [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3370:
URL: https://github.com/apache/cassandra/pull/3370#discussion_r1643085062
##########
src/java/org/apache/cassandra/index/SecondaryIndexManager.java:
##########
@@ -1401,18 +1430,23 @@ public UpdateTransaction newUpdateTransaction(PartitionUpdate update, WriteConte
if (!hasIndexes())
return UpdateTransaction.NO_OP;
- Index.Indexer[] indexers = listIndexGroups().stream()
- .map(g -> g.indexerFor(writableIndexSelector(),
- update.partitionKey(),
- update.columns(),
- nowInSec,
- ctx,
- IndexTransaction.Type.UPDATE,
- memtable))
- .filter(Objects::nonNull)
- .toArray(Index.Indexer[]::new);
-
- return indexers.length == 0 ? UpdateTransaction.NO_OP : new WriteTimeTransaction(indexers);
+ List<Index.Indexer> indexers = new ArrayList<>(indexGroups.size());
+
+ for (Index.Group g : indexGroups.values())
+ {
+ Index.Indexer indexer = g.indexerFor(writableIndexSelector(),
+ update.partitionKey(),
+ update.columns(),
+ nowInSec,
+ ctx,
+ IndexTransaction.Type.UPDATE,
+ memtable);
+ if (indexer != null)
+ indexers.add(indexer);
+ }
+
+ return indexers.isEmpty() ? UpdateTransaction.NO_OP
+ : new WriteTimeTransaction(indexers.toArray(EMPTY_INDEXERS_ARRAY));
Review Comment:
nit: since we are jdk11+ we can do `Index.Indexer[]::new` now
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org