Class LWWDictionary<TKey, TValue>
Specialized LWWDictionary<TKey, TValue> with LWWRegister<T> values.
LWWRegister<T> relies on synchronized clocks and should only be used when the choice of value is not important for concurrent updates occurring within the clock skew.
Instead of using timestamps based on DateTime.UtcNow.Ticks time it is possible to use a timestamp value based on something else, for example an increasing version number from a database record that is used for optimistic concurrency control.
For first-write-wins semantics you can use the ReverseClock instead of the DefaultClock
This class is immutable, i.e. "modifying" methods return a new instance.
Implements
Inherited Members
Namespace: Akka.DistributedData
Assembly: Akka.DistributedData.dll
Syntax
[Serializable]
public sealed class LWWDictionary<TKey, TValue> : IDeltaReplicatedData<LWWDictionary<TKey, TValue>, ORDictionary<TKey, LWWRegister<TValue>>.IDeltaOperation>, IDeltaReplicatedData, IRemovedNodePruning<LWWDictionary<TKey, TValue>>, IRemovedNodePruning, IReplicatedData<LWWDictionary<TKey, TValue>>, IReplicatedData, IReplicatedDataSerialization, IEquatable<LWWDictionary<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| TKey | TBD |
| TValue | TBD |
Constructors
| Edit this page View SourceLWWDictionary(ORDictionary<TKey, LWWRegister<TValue>>)
TBD
Declaration
public LWWDictionary(ORDictionary<TKey, LWWRegister<TValue>> underlying)
Parameters
| Type | Name | Description |
|---|---|---|
| ORDictionary<TKey, LWWRegister<TValue>> | underlying | TBD |
Fields
| Edit this page View SourceEmpty
An empty instance of the LWWDictionary<TKey, TValue>
Declaration
public static readonly LWWDictionary<TKey, TValue> Empty
Field Value
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
Properties
| Edit this page View SourceCount
Returns number of entries stored within current LWWDictionary<TKey, TValue>.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Delta
The accumulated delta of mutator operations since previous
ResetDelta(). When the Akka.DistributedData.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 Akka.DistributedData.Replicator with the Delta accessor. The
modify function shall still return the full state in the same way as
IReplicatedData<T> without support for deltas.
Declaration
public ORDictionary<TKey, LWWRegister<TValue>>.IDeltaOperation Delta { get; }
Property Value
| Type | Description |
|---|---|
| ORDictionary<TKey, LWWRegister<TValue>>.IDeltaOperation |
Entries
Returns all entries stored within current LWWDictionary<TKey, TValue>
Declaration
public IImmutableDictionary<TKey, TValue> Entries { get; }
Property Value
| Type | Description |
|---|---|
| IImmutableDictionary<TKey, TValue> |
IsEmpty
Determines if current LWWDictionary<TKey, TValue> is empty.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
this[TKey]
Returns value stored under provided key.
Declaration
public TValue this[TKey key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | TBD |
Property Value
| Type | Description |
|---|---|
| TValue |
KeyType
Declaration
public Type KeyType { get; }
Property Value
| Type | Description |
|---|---|
| Type |
Keys
Returns collection of keys stored within current LWWDictionary<TKey, TValue>.
Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TKey> |
ModifiedByNodes
The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.
Declaration
public ImmutableHashSet<UniqueAddress> ModifiedByNodes { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableHashSet<UniqueAddress> |
ValueType
Declaration
public Type ValueType { get; }
Property Value
| Type | Description |
|---|---|
| Type |
Values
Returns collection of values stored within current LWWDictionary<TKey, TValue>.
Declaration
public IEnumerable<TValue> Values { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TValue> |
Methods
| Edit this page View SourceContainsKey(TKey)
Determines current LWWDictionary<TKey, TValue> contains entry with provided key.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Equals(LWWDictionary<TKey, TValue>)
TBD
Declaration
public bool Equals(LWWDictionary<TKey, TValue> other)
Parameters
| Type | Name | Description |
|---|---|---|
| LWWDictionary<TKey, TValue> | other | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceGetEnumerator()
TBD
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<KeyValuePair<TKey, TValue>> | TBD |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceMerge(IReplicatedData)
TBD
Declaration
public IReplicatedData Merge(IReplicatedData other)
Parameters
| Type | Name | Description |
|---|---|---|
| IReplicatedData | other | TBD |
Returns
| Type | Description |
|---|---|
| IReplicatedData | TBD |
Merge(LWWDictionary<TKey, TValue>)
TBD
Declaration
public LWWDictionary<TKey, TValue> Merge(LWWDictionary<TKey, TValue> other)
Parameters
| Type | Name | Description |
|---|---|---|
| LWWDictionary<TKey, TValue> | other | TBD |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> | TBD |
MergeDelta(IDeltaOperation)
When delta is merged into the full state this method is used. When the type ORDictionary of the delta is of the same type as the full state LWWDictionary<TKey, TValue> this method can be implemented by delegating to Merge(T).
Declaration
public LWWDictionary<TKey, TValue> MergeDelta(ORDictionary<TKey, LWWRegister<TValue>>.IDeltaOperation delta)
Parameters
| Type | Name | Description |
|---|---|---|
| ORDictionary<TKey, LWWRegister<TValue>>.IDeltaOperation | delta |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
NeedPruningFrom(UniqueAddress)
TBD
Declaration
public bool NeedPruningFrom(UniqueAddress removedNode)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Prune(UniqueAddress, UniqueAddress)
TBD
Declaration
public LWWDictionary<TKey, TValue> Prune(UniqueAddress removedNode, UniqueAddress collapseInto)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
| UniqueAddress | collapseInto | TBD |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> | TBD |
PruningCleanup(UniqueAddress)
TBD
Declaration
public LWWDictionary<TKey, TValue> PruningCleanup(UniqueAddress removedNode)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> | TBD |
Remove(Cluster, TKey)
Removes an entry from the map. Note that if there is a conflicting update on another node the entry will not be removed after merge.
Declaration
public LWWDictionary<TKey, TValue> Remove(Cluster node, TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| Cluster | node | |
| TKey | key |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
Remove(UniqueAddress, TKey)
Removes an entry from the map. Note that if there is a conflicting update on another node the entry will not be removed after merge.
Declaration
public LWWDictionary<TKey, TValue> Remove(UniqueAddress node, TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | node | |
| TKey | key |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
ResetDelta()
Reset collection of deltas from mutator operations. When the Akka.DistributedData.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 Akka.DistributedData.Replicator with the Delta accessor. When the
Akka.DistributedData.Replicator has grabbed the Delta it will invoke this method
to get a clean data instance without the delta.
Declaration
public LWWDictionary<TKey, TValue> ResetDelta()
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
SetItem(Cluster, TKey, TValue, Clock<TValue>)
Adds an entry to the map.
You can provide your clock implementation instead of using timestamps based
on DateTime.UtcNow.Ticks time. The timestamp can for example be an
increasing version number from a database record that is used for optimistic
concurrency control.
Declaration
public LWWDictionary<TKey, TValue> SetItem(Cluster node, TKey key, TValue value, Clock<TValue> clock = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Cluster | node | |
| TKey | key | |
| TValue | value | |
| Clock<TValue> | clock |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
SetItem(UniqueAddress, TKey, TValue, Clock<TValue>)
Adds an entry to the map.
You can provide your clock implementation instead of using timestamps based
on DateTime.UtcNow.Ticks time. The timestamp can for example be an
increasing version number from a database record that is used for optimistic
concurrency control.
Declaration
public LWWDictionary<TKey, TValue> SetItem(UniqueAddress node, TKey key, TValue value, Clock<TValue> clock = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | node | |
| TKey | key | |
| TValue | value | |
| Clock<TValue> | clock |
Returns
| Type | Description |
|---|---|
| LWWDictionary<TKey, TValue> |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceTryGetValue(TKey, out TValue)
Tries to return a value under provided key is such value exists.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | TBD |
| TValue | value | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Edit this page