Permalink
Browse files

Markdown json fixes

  • Loading branch information...
1 parent 65c862e commit fc44ad6851b65f0b09ea675cd94fa9275b8aff65 Kyle Kingsbury committed Jan 5, 2012
Showing with 68 additions and 48 deletions.
  1. +68 −48 README.markdown
View
116 README.markdown
@@ -14,10 +14,11 @@ simultaneous writes to a set *which only allows addition*. You cannot remove an
element of a G-Set.
JSON:
- {
- 'type': 'g-set',
- 'e': ['a', 'b', 'c']
- }
+```json
+{
+ 'type': 'g-set',
+ 'e': ['a', 'b', 'c']
+}
2P-Set
---
@@ -29,11 +30,12 @@ only be removed if they are present in the set. Removes take precedence over
adds.
JSON:
- {
- 'type': '2p-set',
- 'a': ['a', 'b'],
- 'r': ['b']
- }
+```json
+{
+ 'type': '2p-set',
+ 'a': ['a', 'b'],
+ 'r': ['b']
+}
In this set, only 'a' is present.
@@ -52,20 +54,23 @@ The remove set is therefore redundant; one can delete any element which is
present. Simultaneous adds and deletes of the same element are not allowed.
JSON:
- {
- 'type': 'u-set',
- 'a': ['a', 'b', 'c']
- }
+```json
+{
+ 'type': 'u-set',
+ 'a': ['a', 'b', 'c']
+}
LWW-Element-Set
---
LWW-Element-Set is like 2P-Set: it comprises an add G-Set (A) and a remove
G-Set (R), with a timestamp for each element. To add an element e, add (e,
timestamp) to the add set A. To remove e, add (e, timestamp) to the remove set
-R. An element is present iff it is in A, and no *newer* element exists in R. Merging is accomplished by taking the union of all A and all R, respectively.
+R. An element is present iff it is in A, and no *newer* element exists in R.
+Merging is accomplished by taking the union of all A and all R, respectively.
-Since the last write wins, we can safely take only the largest add, and the largest delete. All others can be pruned.
+Since the last write wins, we can safely take only the largest add, and the
+largest delete. All others can be pruned.
When A and R have equal timestamps, the direction of the inequality determines
whether adds or removes win. {'bias': 'a'} indicates that adds win. {'bias':
@@ -77,21 +82,24 @@ traditional consistent Set structure. If non-unique timestamps are used, the
resolution of the timestamp determines the window under which conflicts will be
resolved by the bias towards adds or deletes.
-TODO: define sorting strategies for strings. By byte value, UTF-8 ordering, numeric, etc...
+TODO: define sorting strategies for strings. By byte value, UTF-8 ordering,
+numeric, etc...
-In JSON, we write the set as a list of 2- or 3-tuples: [element, add-time] or [element, add-time, delete-time]
+In JSON, we write the set as a list of 2- or 3-tuples: [element, add-time] or
+[element, add-time, delete-time]
JSON:
- {
- 'type': 'lww-e-set',
- 'bias': 'a',
- 'e': [
- ['a', 0],
- ['b', 1, 2],
- ['c', 2, 1],
- ['d', 3, 3]
- ]
- }
+```json
+{
+ 'type': 'lww-e-set',
+ 'bias': 'a',
+ 'e': [
+ ['a', 0],
+ ['b', 1, 2],
+ ['c', 2, 1],
+ ['d', 3, 3]
+ ]
+}
In this set:
@@ -109,25 +117,29 @@ tags are associated with each insertion or deletion. In the case of conflicting
add and delete, add wins. An element is a member of the set iff the set of
insertion tags less the set of deletion tags is nonempty.
-We write the set as a list of 2- or 3- tuples: [element, [add-tags]] or [element, [add-tags], [remove-tags]]
+We write the set as a list of 2- or 3- tuples: [element, [add-tags]] or
+[element, [add-tags], [remove-tags]]
To insert e, generate a unique tag, and add it to the insertion tag set for e.
-To remove e, take all insertion tags for e, and insert them into the deletion tags for e.
+To remove e, take all insertion tags for e, and insert them into the deletion
+tags for e.
-To merge two OR-Sets, for each element in either set, take the union of the insertion tags and the union of the deletion tags.
+To merge two OR-Sets, for each element in either set, take the union of the
+insertion tags and the union of the deletion tags.
Tags may be any primitive: strings, ints, floats, etc.
JSON:
- {
- 'type': 'or-set',
- 'e': [
- ['a', [1]],
- ['b', [1], [1]],
- ['c', [1, 2], [2, 3]]
- ]
- }
+```json
+{
+ 'type': 'or-set',
+ 'e': [
+ ['a', [1]],
+ ['b', [1], [1]],
+ ['c', [1, 2], [2, 3]]
+ ]
+}
- a exists.
- b's only insertion was deleted, so it does not exist.
@@ -144,21 +156,29 @@ resolution window, but behave arbitrarily when divergent histories each include
many changes.
Each element e is associated with an integer n, implicitly assumed to be zero.
-When n is even, the element is absent from the set. When n is odd, the element is present. To add an element to the set, increment n from an even value by one; to remove an element, increment n from an odd value by one. To merge sets, take each element and choose the maximum value of n from each history.
+When n is even, the element is absent from the set. When n is odd, the element
+is present. To add an element to the set, increment n from an even value by
+one; to remove an element, increment n from an odd value by one. To merge sets,
+take each element and choose the maximum value of n from each history.
-When n is limited to [0, 2], Max-Change-Sets collapse to 2P-Sets. Unlike 2P-Sets, however, one can add and remove an arbitrary number of times. The disadvantage is that there is no bias towards preserving adds or removes. Instead, whichever history has incremented further (undergone more changes) is preferred.
+When n is limited to [0, 2], Max-Change-Sets collapse to 2P-Sets. Unlike
+2P-Sets, however, one can add and remove an arbitrary number of times. The
+disadvantage is that there is no bias towards preserving adds or removes.
+Instead, whichever history has incremented further (undergone more changes) is
+preferred.
In JSON, max-change sets are represented as a list of [element, n] tuples.
JSON:
- {
- 'type': 'mc-set',
- 'e': [
- ['a', 1],
- ['b', 2],
- ['c', 3]
- ]
- }
+```json
+{
+ 'type': 'mc-set',
+ 'e': [
+ ['a', 1],
+ ['b', 2],
+ ['c', 3]
+ ]
+}
- a is present
- b is absent

0 comments on commit fc44ad6

Please sign in to comment.