Skip to content

Commit e12c5a1

Browse files
committed
update docs, statebox_orddict:orddict_from_proplist/1
1 parent fafb1ed commit e12c5a1

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 0.2.2 released 2011-06-14
2+
3+
* Updated README
4+
* statebox_orddict:orddict_from_proplist/1 now uses
5+
orddict:from_list/1 instead of lists:usort/1 for correctness
6+
* Fixed docstring for statebox_orddict:f_subtract/2
7+
18
Version 0.2.1 released 2011-04-30
29

310
* Added LICENSE file (MIT)

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,30 @@ Using the `statebox_orddict` convenience wrapper:
9595
New),
9696
Resovled = statebox_orddict:from_values([ChildA, ChildB]),
9797
statebox:value(Resolved) =:= [{a, 1}, {b, 1}, {c, [a, aa, b, bb]}].
98+
99+
Resources
100+
---------
101+
102+
On Mochi Labs
103+
=============
104+
105+
[statebox, an eventually consistent data model for Erlang (and Riak)][labs0]
106+
on the Mochi Labs blog describes the rationale for statebox and shows how it
107+
works.
108+
109+
[labs0]: http://labs.mochimedia.com/archive/2011/05/08/statebox/
110+
111+
Convergent / Commutative Replicated Data Types
112+
==============================================
113+
114+
The technique used to implement this is similar to what is described in
115+
this paper:
116+
[A comprehensive study of Convergent and Commutative Replicated Data Types][CRDT].
117+
statebox was developed without knowledge of the paper, so the terminology and
118+
implementation details differ.
119+
120+
I think the technique used by statebox would be best described as a
121+
state-based object, although the merge algorithm and event queue
122+
is similar to how op-based objects are described.
123+
124+
[CRDT]: http://hal.archives-ouvertes.fr/inria-00555588/

src/statebox.app.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{application, statebox,
22
[
33
{description, "Erlang state \"monad\" with merge/conflict-resolution capabilities. Useful for Riak."},
4-
{vsn, "0.2.1"},
4+
{vsn, "0.2.2"},
55
{registered, []},
66
{applications, [
77
kernel,

src/statebox_orddict.erl

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ from_values([]) ->
2222
from_values(Vals) ->
2323
statebox:merge([as_statebox(V) || V <- Vals]).
2424

25-
%% @doc Convert a proplist() to an orddict() (by sorting it).
25+
%% @doc Convert a proplist() to an orddict().
2626
%% Only [{term(), term()}] proplists are supported.
2727
-spec orddict_from_proplist(proplist()) -> orddict().
2828
orddict_from_proplist(P) ->
29-
lists:usort(P).
29+
orddict:from_list(P).
3030

3131
%% @doc Return true if the statebox's value is [], false otherwise.
3232
-spec is_empty(statebox()) -> boolean().
@@ -121,6 +121,12 @@ orddict_from_proplist_test() ->
121121
?assertEqual(
122122
[{a, b}, {c, d}],
123123
orddict_from_proplist([{c, d}, {a, b}])),
124+
?assertEqual(
125+
[{a, c}],
126+
orddict_from_proplist([{a, b}, {a, c}])),
127+
?assertEqual(
128+
[{a, b}],
129+
orddict_from_proplist([{a, c}, {a, b}])),
124130
ok.
125131

126132
is_empty_test() ->

0 commit comments

Comments
 (0)