mirror of https://github.com/apache/cassandra
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
This commit is contained in:
parent
f81ece5cd0
commit
f1bec5d0c5
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue