class ReplicatedMap[K, V <: ReplicatedData] extends InternalReplicatedData

A Replicated Map that allows both the addition and removal of kalix.replicatedentity.ReplicatedData objects.

Use the more specialized maps if possible, such as kalix.scalasdk.replicatedentity.ReplicatedCounterMap, kalix.scalasdk.replicatedentity.ReplicatedRegisterMap, and kalix.scalasdk.replicatedentity.ReplicatedMultiMap.

A removal can only be done if all of the additions that caused the key to be in the map have been seen by this node. This means that, for example, if node 1 adds key A, and node 2 also adds key A, then node 1's addition is replicated to node 3, and node 3 deletes it before node 2's addition is replicated, then the item will still be in the map because node 2's addition had not yet been observed by node 3. However, if both additions had been replicated to node 3, then the key will be removed.

The values of the map are themselves kalix.replicatedentity.ReplicatedData types, and hence allow concurrent updates that will eventually converge. New kalix.replicatedentity.ReplicatedData objects may only be created when using the kalix.scalasdk.replicatedentity.ReplicatedMap.getOrElse* method, using the provided kalix.scalasdk.replicatedentity.ReplicatedDataFactory for the create function.

While removing entries from the map is supported, if the entries are added back again, it is possible that the value of the deleted entry may be merged into the value of the current entry, depending on whether the removal has been replicated to all nodes before the addition is performed.

The map may contain different data types as values, however, for a given key, the type must never change. If two different types for the same key are inserted on different nodes, the replicated entity will enter an invalid state that can never be merged, and behavior of the replicated entity is undefined.

Care needs to be taken to ensure that the serialized value of keys in the set is stable. For example, if using protobufs, the serialized value of any maps contained in the protobuf is not stable, and can yield a different set of bytes for the same logically equal element. Hence maps should be avoided. Additionally, some changes in protobuf schemas which are backwards compatible from a protobuf perspective, such as changing from sint32 to int32, do result in different serialized bytes, and so must be avoided.

K

The type of keys.

V

The replicated data type to be used for values.

Source
ReplicatedMap.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReplicatedMap
  2. InternalReplicatedData
  3. InternalReplicatedData
  4. ReplicatedData
  5. AnyRef
  6. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final type Self = ReplicatedMap[K, V]
    Definition Classes
    ReplicatedMap → InternalReplicatedData

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toany2stringadd[ReplicatedMap[K, V]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (ReplicatedMap[K, V], B)
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toArrowAssoc[ReplicatedMap[K, V]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def apply(key: K): V

    Get the kalix.replicatedentity.ReplicatedData value for the given key.

    Get the kalix.replicatedentity.ReplicatedData value for the given key.

    key

    the key of the mapping

    returns

    the kalix.replicatedentity.ReplicatedData for the key

    Exceptions thrown

    java.util.NoSuchElementException if the key is not preset in the map

  7. final def applyDelta: PartialFunction[Delta, ReplicatedMap[K, V]]
    Definition Classes
    ReplicatedMap → InternalReplicatedData
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clear(): ReplicatedMap[K, V]

    Remove all entries from this map.

    Remove all entries from this map.

    returns

    a new empty map

  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  11. def contains(key: K): Boolean

    Check whether this map contains a mapping for the given key.

    Check whether this map contains a mapping for the given key.

    key

    key whose presence in this map is to be tested

    returns

    true if this map contains a mapping for the given key

  12. val delegate: ReplicatedMapImpl[K, V]
  13. def ensuring(cond: (ReplicatedMap[K, V]) => Boolean, msg: => Any): ReplicatedMap[K, V]
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toEnsuring[ReplicatedMap[K, V]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (ReplicatedMap[K, V]) => Boolean): ReplicatedMap[K, V]
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toEnsuring[ReplicatedMap[K, V]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: => Any): ReplicatedMap[K, V]
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toEnsuring[ReplicatedMap[K, V]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): ReplicatedMap[K, V]
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toEnsuring[ReplicatedMap[K, V]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  19. def get(key: K): Option[V]

    Optionally returns the kalix.replicatedentity.ReplicatedData value for the given key.

    Optionally returns the kalix.replicatedentity.ReplicatedData value for the given key.

    key

    the key of the mapping

    returns

    an option value containing the value associated with key in this kalix.scalasdk.replicatedentity.ReplicatedMap, or None if none exists.

  20. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  21. def getDelta: Delta
    Definition Classes
    InternalReplicatedData → InternalReplicatedData
  22. def getOrElse[ValueT <: ReplicatedData](key: K, create: (ReplicatedDataFactory) => ValueT): ValueT

    Get the kalix.replicatedentity.ReplicatedData value for the given key.

    Get the kalix.replicatedentity.ReplicatedData value for the given key. If the key is not present in the map, then a new value is created with a creation function.

    key

    the key of the mapping

    create

    function used to create an empty value using the given kalix.scalasdk.replicatedentity.ReplicatedDataFactory if the key is not present in the map

    returns

    the kalix.replicatedentity.ReplicatedData for the key

  23. def getReplicatedCounter(key: K): ReplicatedCounter

    Get a kalix.scalasdk.replicatedentity.ReplicatedCounter from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedCounter from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    key

    the key for a Replicated Counter in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedCounter associated with the given key, or an empty counter

  24. def getReplicatedCounterMap[KeyT](key: K): ReplicatedCounterMap[KeyT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedCounterMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedCounterMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    KeyT

    the key type for the Replicated Counter Map

    key

    the key for a Replicated Counter Map in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedCounterMap associated with the given key, or an empty map

  25. def getReplicatedMap[KeyT, ValueT <: ReplicatedData](key: K): ReplicatedMap[KeyT, ValueT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    KeyT

    the key type for the Replicated Map

    ValueT

    the value type for the Replicated Map

    key

    the key for a Replicated Map in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedMap associated with the given key, or an empty map

  26. def getReplicatedMultiMap[KeyT, ValueT](key: K): ReplicatedMultiMap[KeyT, ValueT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedMultiMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedMultiMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    KeyT

    the key type for the Replicated Multi-Map

    ValueT

    the value type for the Replicated Multi-Map

    key

    the key for a Replicated Multi-Map in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedMultiMap associated with the given key, or an empty multi-map

  27. def getReplicatedRegister[ValueT](key: K, defaultValue: () => ValueT): ReplicatedRegister[ValueT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegister from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegister from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    ValueT

    the value type for the Replicated Register

    key

    the key for a Replicated Register in this map

    defaultValue

    the supplier for a default value when the register is not present

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedRegister associated with the given key, or a default register

  28. def getReplicatedRegister[ValueT <: AnyRef](key: K): ReplicatedRegister[ValueT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegister from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegister from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    ValueT

    the value type for the Replicated Register

    key

    the key for a Replicated Register in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedRegister associated with the given key, or an empty register

  29. def getReplicatedRegisterMap[KeyT, ValueT](key: K): ReplicatedRegisterMap[KeyT, ValueT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegisterMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedRegisterMap from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    KeyT

    the key type for the Replicated Register Map

    ValueT

    the value type for the Replicated Register Map

    key

    the key for a Replicated Register Map in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedRegisterMap associated with the given key, or an empty map

  30. def getReplicatedSet[ElementT](key: K): ReplicatedSet[ElementT]

    Get a kalix.scalasdk.replicatedentity.ReplicatedSet from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    Get a kalix.scalasdk.replicatedentity.ReplicatedSet from a heterogeneous Replicated Map (a map with different types of Replicated Data values).

    ElementT

    the element type for the Replicated Set

    key

    the key for a Replicated Set in this map

    returns

    the kalix.scalasdk.replicatedentity.ReplicatedSet associated with the given key, or an empty set

  31. def hasDelta: Boolean
    Definition Classes
    InternalReplicatedData → InternalReplicatedData
  32. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  33. def isEmpty: Boolean

    Check whether this map is empty.

    Check whether this map is empty.

    returns

    true if this map contains no key-value mappings

  34. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  35. def keySet: Set[K]

    Get a scala.collection.immutable.Set view of the keys contained in this map.

    Get a scala.collection.immutable.Set view of the keys contained in this map.

    returns

    the keys contained in this map

  36. def name: String
    Definition Classes
    InternalReplicatedData → InternalReplicatedData
  37. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  38. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  39. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  40. def remove(key: K): ReplicatedMap[K, V]

    Remove the mapping for a key if it is present.

    Remove the mapping for a key if it is present.

    key

    key whose mapping is to be removed from the map

    returns

    a new map with the removed mapping

  41. final def resetDelta(): ReplicatedMap[K, V]
    Definition Classes
    ReplicatedMap → InternalReplicatedData
  42. def size: Int

    Get the number of key-value mappings in this map.

    Get the number of key-value mappings in this map.

    returns

    the number of key-value mappings in this map

  43. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  44. def toString(): String
    Definition Classes
    AnyRef → Any
  45. def update(key: K, value: V): ReplicatedMap[K, V]

    Update the kalix.replicatedentity.ReplicatedData value associated with the given key.

    Update the kalix.replicatedentity.ReplicatedData value associated with the given key.

    key

    the key of the mapping

    value

    the updated kalix.replicatedentity.ReplicatedData value

    returns

    a new map with the updated value

  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  48. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

  2. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toStringFormat[ReplicatedMap[K, V]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  3. def [B](y: B): (ReplicatedMap[K, V], B)
    Implicit
    This member is added by an implicit conversion from ReplicatedMap[K, V] toArrowAssoc[ReplicatedMap[K, V]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from InternalReplicatedData

Inherited from ReplicatedData

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromReplicatedMap[K, V] to any2stringadd[ReplicatedMap[K, V]]

Inherited by implicit conversion StringFormat fromReplicatedMap[K, V] to StringFormat[ReplicatedMap[K, V]]

Inherited by implicit conversion Ensuring fromReplicatedMap[K, V] to Ensuring[ReplicatedMap[K, V]]

Inherited by implicit conversion ArrowAssoc fromReplicatedMap[K, V] to ArrowAssoc[ReplicatedMap[K, V]]

Ungrouped