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:
  • Method Details

    • _empty

      public static ORMultiMap<Object,Object> _empty()
    • _emptyWithValueDeltas

      public static ORMultiMap<Object,Object> _emptyWithValueDeltas()
    • empty

      public static <A, B> ORMultiMap<A,B> empty()
      Provides an empty multimap.
    • emptyWithValueDeltas

      public static <A, B> ORMultiMap<A,B> emptyWithValueDeltas()
    • apply

      public static ORMultiMap<Object,Object> apply()
    • create

      public static <A, B> ORMultiMap<A,B> 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 the entries().
    • unapply

      public static <A, B extends ReplicatedData> scala.Option<scala.collection.immutable.Map<A,scala.collection.immutable.Set<B>>> unapply(Object value)
      Extract the entries() of an ORMultiMap.
    • merge

      public ORMultiMap<A,B> merge(ORMultiMap<A,B> that)
    • entries

      public scala.collection.immutable.Map<A,scala.collection.immutable.Set<B>> entries()
      Scala API: All entries of a multimap where keys are strings and values are sets.
    • getEntries

      public Map<A,Set<B>> getEntries()
      Java API: All entries of a multimap where keys are strings and values are sets.
    • get

      public scala.Option<scala.collection.immutable.Set<B>> get(A key)
      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

      public boolean contains(A key)
    • 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

      public 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.
    • put

      public 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.
    • remove

      public ORMultiMap<A,B> remove(A key, SelfUniqueAddress node)
      Scala API Remove an entire set associated with the key.
    • remove

      public ORMultiMap<A,B> remove(SelfUniqueAddress node, A key)
      Java API Remove an entire set associated with the key.
    • addBinding

      public ORMultiMap<A,B> addBinding(SelfUniqueAddress node, A key, B element)
      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

      public ORMultiMap<A,B> addBindingBy(A key, B element, SelfUniqueAddress node)
    • removeBinding

      public ORMultiMap<A,B> removeBinding(SelfUniqueAddress node, A key, B element)
      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

      public ORMultiMap<A,B> removeBindingBy(A key, B element, SelfUniqueAddress node)
    • replaceBinding

      public 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. 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

      public ORMultiMap<A,B> replaceBindingBy(A key, B oldElement, B newElement, SelfUniqueAddress node)
    • resetDelta

      public ORMultiMap<A,B> resetDelta()
      Description copied from interface: DeltaReplicatedData
      Reset collection of deltas from mutator operations. When the Replicator invokes the modify function of the Update 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 the Replicator with the DeltaReplicatedData.delta() accessor. When the Replicator has grabbed the delta it will invoke this method to get a clean data instance without the delta.
      Specified by:
      resetDelta in interface DeltaReplicatedData
    • delta

      public scala.Option<ORMap.DeltaOp> delta()
      Description copied from interface: DeltaReplicatedData
      The accumulated delta of mutator operations since previous DeltaReplicatedData.resetDelta(). When the Replicator invokes the modify function of the Update 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 the Replicator with the DeltaReplicatedData.delta() accessor. The modify function shall still return the full state in the same way as ReplicatedData without support for deltas.
      Specified by:
      delta in interface DeltaReplicatedData
    • mergeDelta

      public ORMultiMap<A,B> mergeDelta(ORMap.DeltaOp thatDelta)
    • modifiedByNodes

      public scala.collection.immutable.Set<UniqueAddress> 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 interface RemovedNodePruning
    • needPruningFrom

      public boolean needPruningFrom(UniqueAddress removedNode)
      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 interface RemovedNodePruning
    • pruningCleanup

      public ORMultiMap<A,B> pruningCleanup(UniqueAddress removedNode)
      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 interface RemovedNodePruning
    • prune

      public ORMultiMap<A,B> prune(UniqueAddress removedNode, UniqueAddress collapseInto)
      Description copied from interface: RemovedNodePruning
      When the removed 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 interface RemovedNodePruning
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object