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 f1bec5d0c5 Improve performance of DistributedSchema.validate for large
schemas
f1bec5d0c5 is described below
commit f1bec5d0c5dccce4128b3ff9bc087cdf0577f2b0
Author: Abe Ratnofsky <[email protected]>
AuthorDate: Sun Feb 23 11:32:51 2025 -0500
Improve performance of DistributedSchema.validate for large schemas
patch by Abe Ratnofsky; reviewed by Caleb Rackliffe, Benedict Elliott
Smith, Matt Byrd, Sam Tunnicliffe for CASSANDRA-20360
---
CHANGES.txt | 1 +
.../cassandra/utils/btree/AbstractBTreeMap.java | 28 +++++++++++++++++-----
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 3e63e11f67..afda96a8f7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
5.1
+ * Improve performance of DistributedSchema.validate for large schemas
(CASSANDRA-20360)
* Add JSON constraint (CASSANDRA-20273)
* Prevent invalid constraint combinations (CASSANDRA-20330)
* Support CREATE TABLE LIKE WITH INDEXES (CASSANDRA-19965)
diff --git a/src/java/org/apache/cassandra/utils/btree/AbstractBTreeMap.java
b/src/java/org/apache/cassandra/utils/btree/AbstractBTreeMap.java
index 0db33a52cc..3d0baf08f1 100644
--- a/src/java/org/apache/cassandra/utils/btree/AbstractBTreeMap.java
+++ b/src/java/org/apache/cassandra/utils/btree/AbstractBTreeMap.java
@@ -18,13 +18,15 @@
package org.apache.cassandra.utils.btree;
+import java.util.AbstractCollection;
import java.util.AbstractMap;
+import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterators;
public abstract class AbstractBTreeMap<K, V> extends AbstractMap<K, V>
{
@@ -105,13 +107,27 @@ public abstract class AbstractBTreeMap<K, V> extends
AbstractMap<K, V>
return keySet;
}
+ /**
+ * This method, according to the contract of {@link Map#values()}, returns
a collection backed by the map. It also
+ * closely mirrors {@link AbstractMap#values()}, which returns an {@link
AbstractCollection}.
+ */
@Override
- public Set<V> values()
+ public Collection<V> values()
{
- ImmutableSet.Builder<V> b = ImmutableSet.builder();
- for (Map.Entry<K, V> e : entrySet())
- b.add(e.getValue());
- return b.build();
+ return new AbstractCollection<>()
+ {
+ @Override
+ public Iterator<V> iterator()
+ {
+ return Iterators.transform(BTree.<Entry<K, V>>iterator(tree),
Entry::getValue);
+ }
+
+ @Override
+ public int size()
+ {
+ return AbstractBTreeMap.this.size();
+ }
+ };
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]