This is an automated email from the ASF dual-hosted git repository.
maedhroz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new ce035b0215 Restore optimization in MultiCBuilder around building one
clustering
ce035b0215 is described below
commit ce035b021542717a61972a00fe341d9ac9f829d3
Author: Caleb Rackliffe <[email protected]>
AuthorDate: Mon Dec 9 17:21:21 2024 -0600
Restore optimization in MultiCBuilder around building one clustering
patch by Caleb Rackliffe; reviewed by Benjamin Lerer, Abe Ratnofsky, and
Bernardo Botella for CASSANDRA-20129
---
CHANGES.txt | 1 +
src/java/org/apache/cassandra/db/MultiCBuilder.java | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/CHANGES.txt b/CHANGES.txt
index 88443f88c3..b3c4f13bec 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
5.1
+ * Restore optimization in MultiCBuilder around building one clustering
(CASSANDRA-20129)
* Consolidate all snapshot management to SnapshotManager and introduce
SnapshotManagerMBean (CASSANDRA-18111)
* Fix RequestFailureReason constants codes (CASSANDRA-20126)
* Introduce SSTableSimpleScanner for compaction (CASSANDRA-20092)
diff --git a/src/java/org/apache/cassandra/db/MultiCBuilder.java
b/src/java/org/apache/cassandra/db/MultiCBuilder.java
index 99bbc64a65..6e9cf5cd5b 100644
--- a/src/java/org/apache/cassandra/db/MultiCBuilder.java
+++ b/src/java/org/apache/cassandra/db/MultiCBuilder.java
@@ -17,6 +17,7 @@
*/
package org.apache.cassandra.db;
+import java.nio.ByteBuffer;
import java.util.List;
import java.util.NavigableSet;
import java.util.Set;
@@ -193,6 +194,11 @@ public final class MultiCBuilder
if (clusterings.isEmpty())
return BTreeSet.of(comparator, Clustering.EMPTY);
+ // If we have one clustering, avoid unnecessary builder and iterator
allocations that would otherwise follow.
+ // This is a very hot path, touched by both reads and writes.
+ if (clusterings.size() == 1)
+ return BTreeSet.of(comparator,
Clustering.make(clusterings.get(0).toArray(new ByteBuffer[comparator.size()])));
+
CBuilder builder = CBuilder.create(comparator);
BTreeSet.Builder<Clustering<?>> set =
BTreeSet.builder(builder.comparator());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]