Package org.apache.pekko.cluster.ddata
Class ORMultiMap<A,B>
java.lang.Object
org.apache.pekko.cluster.ddata.ORMultiMap<A,B>
- All Implemented Interfaces:
Serializable
,DeltaReplicatedData
,RemovedNodePruning
,ReplicatedData
,ReplicatedDataSerialization
public final class ORMultiMap<A,B>
extends Object
implements DeltaReplicatedData, ReplicatedDataSerialization, RemovedNodePruning
An immutable multi-map implementation. This class wraps an
ORMap
with an ORSet
for the map's value.
This class is immutable, i.e. "modifying" methods return a new instance.
Note that on concurrent adds and removals for the same key (on the same set), removals can be lost.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
INTERNAL APIstatic class
INTERNAL API -
Method Summary
Modifier and TypeMethodDescriptionstatic ORMultiMap<Object,
Object> _empty()
static ORMultiMap<Object,
Object> ORMultiMap<A,
B> $colon$plus
(scala.Tuple2<A, scala.collection.immutable.Set<B>> entry, SelfUniqueAddress node) Convenience for put.ORMultiMap<A,
B> addBinding
(SelfUniqueAddress node, A key, B element) Add an element to a set associated with a key.ORMultiMap<A,
B> addBindingBy
(A key, B element, SelfUniqueAddress node) static ORMultiMap<Object,
Object> apply()
boolean
static <A,
B> ORMultiMap<A, B> create()
Java APIscala.Option<ORMap.DeltaOp>
delta()
The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta()
.static <A,
B> ORMultiMap<A, B> empty()
Provides an empty multimap.static <A,
B> ORMultiMap<A, B> entries()
Scala API: All entries of a multimap where keys are strings and values are sets.boolean
scala.Option<scala.collection.immutable.Set<B>>
Get the set associated with the key if there is one.Java API: All entries of a multimap where keys are strings and values are sets.scala.collection.immutable.Set<B>
Scala API: Get the set associated with the key if there is one, else return the given default.int
hashCode()
boolean
isEmpty()
ORMultiMap<A,
B> merge
(ORMultiMap<A, B> that) ORMultiMap<A,
B> mergeDelta
(ORMap.DeltaOp thatDelta) scala.collection.immutable.Set<UniqueAddress>
The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.boolean
needPruningFrom
(UniqueAddress removedNode) Does it have any state changes from a specific node, which has been removed from the cluster.ORMultiMap<A,
B> prune
(UniqueAddress removedNode, UniqueAddress collapseInto) When theremoved
node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.ORMultiMap<A,
B> pruningCleanup
(UniqueAddress removedNode) Remove data entries from a node that has been removed from the cluster and already been pruned.ORMultiMap<A,
B> put
(SelfUniqueAddress node, A key, Set<B> value) Java API: Associate an entire set with the key while retaining the history of the previous replicated data set.ORMultiMap<A,
B> put
(SelfUniqueAddress node, A key, scala.collection.immutable.Set<B> value) Scala API: Associate an entire set with the key while retaining the history of the previous replicated data set.ORMultiMap<A,
B> remove
(A key, SelfUniqueAddress node) Scala API Remove an entire set associated with the key.ORMultiMap<A,
B> remove
(SelfUniqueAddress node, A key) Java API Remove an entire set associated with the key.ORMultiMap<A,
B> removeBinding
(SelfUniqueAddress node, A key, B element) Remove an element of a set associated with a key.ORMultiMap<A,
B> removeBindingBy
(A key, B element, SelfUniqueAddress node) ORMultiMap<A,
B> replaceBinding
(SelfUniqueAddress node, A key, B oldElement, B newElement) Replace an element of a set associated with a key with a new one if it is different.ORMultiMap<A,
B> replaceBindingBy
(A key, B oldElement, B newElement, SelfUniqueAddress node) ORMultiMap<A,
B> Reset collection of deltas from mutator operations.int
size()
toString()
static <A,
B extends ReplicatedData>
scala.Option<scala.collection.immutable.Map<A,scala.collection.immutable.Set<B>>> Extract theentries()
of anORMultiMap
.static <A,
B> scala.Option<scala.collection.immutable.Map<A, scala.collection.immutable.Set<B>>> unapply
(ORMultiMap<A, B> m) Extract theentries()
.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.pekko.cluster.ddata.DeltaReplicatedData
mergeDelta
Methods inherited from interface org.apache.pekko.cluster.ddata.ReplicatedData
merge
-
Method Details
-
_empty
-
_emptyWithValueDeltas
-
empty
Provides an empty multimap. -
emptyWithValueDeltas
-
apply
-
create
Java API -
unapply
public static <A,B> scala.Option<scala.collection.immutable.Map<A,scala.collection.immutable.Set<B>>> unapply(ORMultiMap<A, B> m) Extract theentries()
. -
unapply
public static <A,B extends ReplicatedData> scala.Option<scala.collection.immutable.Map<A,scala.collection.immutable.Set<B>>> unapply(Object value) Extract theentries()
of anORMultiMap
. -
merge
-
entries
Scala API: All entries of a multimap where keys are strings and values are sets. -
getEntries
Java API: All entries of a multimap where keys are strings and values are sets. -
get
Get the set associated with the key if there is one. -
getOrElse
public scala.collection.immutable.Set<B> getOrElse(A key, scala.Function0<scala.collection.immutable.Set<B>> default_) Scala API: Get the set associated with the key if there is one, else return the given default. -
contains
-
isEmpty
public boolean isEmpty() -
size
public int size() -
$colon$plus
public ORMultiMap<A,B> $colon$plus(scala.Tuple2<A, scala.collection.immutable.Set<B>> entry, SelfUniqueAddress node) Convenience for put. Requires an implicit SelfUniqueAddress. -
put
Scala API: Associate an entire set with the key while retaining the history of the previous replicated data set. -
put
Java API: Associate an entire set with the key while retaining the history of the previous replicated data set. -
remove
Scala API Remove an entire set associated with the key. -
remove
Java API Remove an entire set associated with the key. -
addBinding
Add an element to a set associated with a key. If there is no existing set then one will be initialised. TODO add implicit after deprecated is EOL. -
addBindingBy
-
removeBinding
Remove an element of a set associated with a key. If there are no more elements in the set then the entire set will be removed. TODO add implicit after deprecated is EOL. -
removeBindingBy
-
replaceBinding
Replace an element of a set associated with a key with a new one if it is different. This is useful when an element is removed and another one is added within the same Update. The order of addition and removal is important in order to retain history for replicated data. -
replaceBindingBy
-
resetDelta
Description copied from interface:DeltaReplicatedData
Reset collection of deltas from mutator operations. When theReplicator
invokes themodify
function of theUpdate
message the delta is always "reset" and when the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for theReplicator
with theDeltaReplicatedData.delta()
accessor. When theReplicator
has grabbed thedelta
it will invoke this method to get a clean data instance without the delta.- Specified by:
resetDelta
in interfaceDeltaReplicatedData
-
delta
Description copied from interface:DeltaReplicatedData
The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta()
. When theReplicator
invokes themodify
function of theUpdate
message and the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for theReplicator
with theDeltaReplicatedData.delta()
accessor. Themodify
function shall still return the full state in the same way asReplicatedData
without support for deltas.- Specified by:
delta
in interfaceDeltaReplicatedData
-
mergeDelta
-
modifiedByNodes
Description copied from interface:RemovedNodePruning
The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.- Specified by:
modifiedByNodes
in interfaceRemovedNodePruning
-
needPruningFrom
Description copied from interface:RemovedNodePruning
Does it have any state changes from a specific node, which has been removed from the cluster.- Specified by:
needPruningFrom
in interfaceRemovedNodePruning
-
pruningCleanup
Description copied from interface:RemovedNodePruning
Remove data entries from a node that has been removed from the cluster and already been pruned.- Specified by:
pruningCleanup
in interfaceRemovedNodePruning
-
prune
Description copied from interface:RemovedNodePruning
When theremoved
node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.- Specified by:
prune
in interfaceRemovedNodePruning
-
toString
-
equals
-
hashCode
public int hashCode()
-