This repository implements and tests several state-based conflict free replicated data types (CRDTs).
The repository contains three directories:
coreincluding basic data types that are used in implementing CRDTs,statebasedcontaining the implementation of state based CRDTs, andtestincluding test suites for both basic data types and state based CRDTs.
The statebased folder also provides the development guide of using implemented CRDTs. For source code examples of using CRDTs look at the test folder.
We use Google Test for testing.
Script setup.sh from the root folder of this repository installs Google Test.
sudo ./setup.shRun test.sh from the root folder of this repository to test the entire implementation.
This script compiles the repository, places the compiled files in the folder install, and
creates and executes a binary file crdts_test that runs test cases. Run the following to test the repository:
./test.shThe repository implements a last writer wins register, an optimized observed removed set, and a add wins observed removed map.
A LWWRegister is a variant of a register, i.e., a memory cell that stores a value [1]. A LWWRegister exposes the following operations:
valuethat queries the most recent value of the local LWWRegister object,assignthat assigns a given value to the local LWWRegister object, andmergethat "merges" a LWWRegister received at a downstream replica with the local LWWRegister object.
An optimized observed removed set (ORSet) [2] is a variant of set, that is, a collection of unique elements.
A set exposes the following operations:
addthat add an element to to the local ORSet object,removethat removes an element from the local ORSet object,containsthat queries the existence of a given element in the local ORSet object, andmergethat merges an ORSet received at a downstream replica with the local ORSet object.
Map implements a convergent key value store. A map exposes the following operations,
getthat returns a value associated to a given key,containsthat checks the existence of a given key,putthat takes a key and value and add them to the map,removethat deletes a given key and its associated value, andmergethat merges a map received at a downstream replica with the local object.
[1] Shapiro, M., Preguiça, N., Baquero, C., & Zawirski, M. (2011, October). Conflict-free replicated data types. In Symposium on Self-Stabilizing Systems (pp. 386-400). Springer, Berlin, Heidelberg.
[2] Bieniusa A, Zawirski M, Preguiça N, Shapiro M, Baquero C, Balegas V, Duarte S. (2012). An optimized conflict-free replicated set arXiv preprint arXiv:1210.3368.