+cdd #16799 Add ORMultiMap data type

This commit is contained in:
Christopher Hunt 2015-06-18 16:17:53 +02:00 committed by Patrik Nordwall
parent cbe5dd2cf5
commit 7041c76ba9
12 changed files with 2083 additions and 50 deletions

View file

@ -325,6 +325,19 @@ class DistributedDataDocSpec extends AkkaSpec(DistributedDataDocSpec.config) {
//#orset
}
"demonstrate ORMultiMap" in {
def println(o: Any): Unit = ()
//#ormultimap
implicit val node = Cluster(system)
val m0 = ORMultiMap.empty[Int]
val m1 = m0 + ("a" -> Set(1, 2, 3))
val m2 = m1.addBinding("a", 4)
val m3 = m2.removeBinding("a", 2)
val m4 = m3.addBinding("b", 1)
println(m4.entries)
//#ormultimap
}
"demonstrate Flag" in {
def println(o: Any): Unit = ()
//#flag

View file

@ -240,7 +240,7 @@ by this package, such as:
* Counters: ``GCounter``, ``PNCounter``
* Sets: ``GSet``, ``ORSet``
* Maps: ``ORMap``, ``LWWMap``, ``PNCounterMap``
* Maps: ``ORMap``, ``ORMultiMap``, ``LWWMap``, ``PNCounterMap``
* Registers: ``LWWRegister``, ``Flag``
Counters
@ -303,12 +303,17 @@ It is rather inconvenient to use the ``ORMap`` directly since it does not expose
of the values. The ``ORMap`` is intended as a low level tool for building more specific maps,
such as the following specialized maps.
``ORMultiMap`` (observed-remove multi-map) is a multi-map implementation that wraps an
``ORMap`` with an ``ORSet`` for the map's value.
``PNCounterMap`` (positive negative counter map) is a map of named counters. It is a specialized
``ORMap`` with ``PNCounter`` values.
``LWWMap`` (last writer wins map) is a specialized ``ORMap`` with ``LWWRegister`` (last writer wins register)
values.
.. includecode:: code/docs/ddata/DistributedDataDocSpec.scala#ormultimap
Note that ``LWWRegister`` and therefore ``LWWMap`` 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.