Class AbstractReplicaCollection<C extends AbstractReplicaCollection<C>>
- All Implemented Interfaces:
Iterable<Replica>,ReplicaCollection<C>
- Direct Known Subclasses:
Endpoints,RangesAtEndpoint
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classA simple list with no comodification checks and immutability by default (only append permitted, and only one initial copy) this permits us to reduce the amount of garbage generated, by not wrapping iterators or unnecessarily copying and reduces the amount of indirection necessary, as well as ensuring monomorphic callsites TODO flatten into AbstractReplicaCollection?protected static classA simple map that ensures the underlying list's iteration order is maintained, and can be shared with subLists (either produced via subList, or via filter that naturally produced a subList).Nested classes/interfaces inherited from interface org.apache.cassandra.locator.ReplicaCollection
ReplicaCollection.Builder<C extends ReplicaCollection<C>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AbstractReplicaCollection.ReplicaListprotected final AbstractReplicaCollection.ReplicaList -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanfinal <T> List<T>static <C extends ReplicaCollection<C>,B extends ReplicaCollection.Builder<C>>
Collector<Replica,B, C> collector(Set<Collector.Characteristics> characteristics, Supplier<B> supplier) final intfinal booleanIt's not clear whetherAbstractReplicaCollectionshould implement the order sensitiveequalsofListor the order obliviousequalsofSet.final Cfinal CfilterLazily(Predicate<? super Replica> predicate) filterLazily(Predicate<? super Replica> predicate, int limit) final voidfinal Replicaget(int i) final inthashCode()It's not clear whetherAbstractReplicaCollectionshould implement the order sensitivehashCodeofListor the order obliviousequalsofSet.final booleanisEmpty()iterator()abstract ReplicaCollection.Builder<C>newBuilder(int initialCapacity) construct a new Builder of our own type, so that we can concatenate TODO: this isn't terribly pretty, but we need sometimes to select / merge two Endpoints of unknown type;final intsize()abstract Csnapshot()final Csorted(Comparator<? super Replica> comparator) stream()final CsubList(int start, int end) final StringtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
spliteratorMethods inherited from interface org.apache.cassandra.locator.ReplicaCollection
contains, endpoints
-
Field Details
-
EMPTY_LIST
-
list
-
-
Method Details
-
collector
public static <C extends ReplicaCollection<C>,B extends ReplicaCollection.Builder<C>> Collector<Replica,B, collectorC> (Set<Collector.Characteristics> characteristics, Supplier<B> supplier) -
newBuilder
construct a new Builder of our own type, so that we can concatenate TODO: this isn't terribly pretty, but we need sometimes to select / merge two Endpoints of unknown type; -
snapshot
-
subList
- Specified by:
subListin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- an *eagerly constructed* copy of this collection containing the Replica at positions [start..end); An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
asList
-
count
- Specified by:
countin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- the number of replicas that match the predicate
-
anyMatch
-
filter
- Specified by:
filterin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
filter
- Specified by:
filterin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result. Only the first maxSize items will be returned.
-
filterLazily
- Specified by:
filterLazilyin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate.
-
filterLazily
- Specified by:
filterLazilyin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate. Only the first maxSize matching items will be returned.
-
sorted
- Specified by:
sortedin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- an *eagerly constructed* copy of this collection containing the Replica re-ordered according to this comparator It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
get
- Specified by:
getin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Parameters:
i- a value in the range [0..size())- Returns:
- the i'th Replica, in our iteration order
-
size
public final int size()- Specified by:
sizein interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- the number of Replica contained
-
isEmpty
public final boolean isEmpty()- Specified by:
isEmptyin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Returns:
- true iff size() == 0
-
iterator
- Specified by:
iteratorin interfaceIterable<C extends AbstractReplicaCollection<C>>- Specified by:
iteratorin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>
-
forEach
- Specified by:
forEachin interfaceIterable<C extends AbstractReplicaCollection<C>>
-
stream
- Specified by:
streamin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>
-
equals
It's not clear whether
AbstractReplicaCollectionshould implement the order sensitiveequalsofListor the order obliviousequalsofSet. We never rely on equality in the database so rather then leave in a potentially surprising implementation we have it throwUnsupportedOperationException.Don't implement this and pick one behavior over the other. If you want equality you can static import
Iterables.elementsEqual(Iterable, Iterable)and use that to get order sensitive equals.- Specified by:
equalsin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Overrides:
equalsin classObject
-
hashCode
public final int hashCode()It's not clear whether
AbstractReplicaCollectionshould implement the order sensitivehashCodeofListor the order obliviousequalsofSet. We never rely on hashCode in the database so rather then leave in a potentially surprising implementation we have it throwUnsupportedOperationException.Don't implement this and pick one behavior over the other.
- Specified by:
hashCodein interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Overrides:
hashCodein classObject
-
toString
- Specified by:
toStringin interfaceReplicaCollection<C extends AbstractReplicaCollection<C>>- Overrides:
toStringin classObject
-