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
- Alphabetic
- By Inheritance
- ReplicatedMap
- InternalReplicatedData
- InternalReplicatedData
- ReplicatedData
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- final type Self = ReplicatedMap[K, V]
- Definition Classes
- ReplicatedMap → InternalReplicatedData
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- 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
- 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()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- 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
- final def applyDelta: PartialFunction[Delta, ReplicatedMap[K, V]]
- Definition Classes
- ReplicatedMap → InternalReplicatedData
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clear(): ReplicatedMap[K, V]
Remove all entries from this map.
Remove all entries from this map.
- returns
a new empty map
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- 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
- val delegate: ReplicatedMapImpl[K, V]
- Definition Classes
- ReplicatedMap → InternalReplicatedData
- 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
- 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
- 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
- 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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, orNone
if none exists.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getDelta: Delta
- Definition Classes
- InternalReplicatedData → InternalReplicatedData
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- def hasDelta: Boolean
- Definition Classes
- InternalReplicatedData → InternalReplicatedData
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- 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
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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
- def name: String
- Definition Classes
- InternalReplicatedData → InternalReplicatedData
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- 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
- final def resetDelta(): ReplicatedMap[K, V]
- Definition Classes
- ReplicatedMap → InternalReplicatedData
- 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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- 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 ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- 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.