All Projects → neurodrone → Crdt

neurodrone / Crdt

Licence: mit
A Golang implementation of CRDTs.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Crdt

Crdts
A library of Conflict-Free Replicated Data Types for JavaScript
Stars: ✭ 143 (-18.75%)
Mutual labels:  data-structures, crdt
Cpg
CloudI Process Groups
Stars: ✭ 87 (-50.57%)
Mutual labels:  data-structures, crdt
Pygm
🐍 Python library implementing sorted containers with state-of-the-art query performance and compressed memory usage
Stars: ✭ 156 (-11.36%)
Mutual labels:  data-structures
Keyvi
Keyvi - a key value index that powers Cliqz search engine. It is an in-memory FST-based data structure highly optimized for size and lookup performance.
Stars: ✭ 171 (-2.84%)
Mutual labels:  data-structures
Blog
Our open source benchmarks and code samples
Stars: ✭ 162 (-7.95%)
Mutual labels:  data-structures
Rea
Lightweight library of data structures implemented in C++11, designed for constant time insertion, erasure, lookup, and fastest possible iteration.
Stars: ✭ 157 (-10.8%)
Mutual labels:  data-structures
Lru Cache
💫 A feature complete LRU cache implementation in C++
Stars: ✭ 162 (-7.95%)
Mutual labels:  data-structures
Icmc Usp
"If You're Going Through Hell, Keep Going" - Winston Churchill 🐢 🐢 🐢
Stars: ✭ 156 (-11.36%)
Mutual labels:  data-structures
Algorithms Data Structures In Typescript
Stars: ✭ 175 (-0.57%)
Mutual labels:  data-structures
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (-8.52%)
Mutual labels:  data-structures
Crdt
CRDT Tutorial for Beginners (a digestible explanation with less math!)
Stars: ✭ 167 (-5.11%)
Mutual labels:  crdt
Sdb
Simple and fast string based key-value database with support for arrays and json
Stars: ✭ 159 (-9.66%)
Mutual labels:  data-structures
Data Structures Algorithms
Your personal library of every algorithm and data structure code that you will ever encounter
Stars: ✭ 157 (-10.8%)
Mutual labels:  data-structures
Cs offer
计算机学科基础知识和主流编程语言相关内容的总结
Stars: ✭ 2,016 (+1045.45%)
Mutual labels:  data-structures
Algorithms Leetcode Javascript
Algorithms resolution in Javascript. Leetcode - Geeksforgeeks - Careercup
Stars: ✭ 157 (-10.8%)
Mutual labels:  data-structures
Extcore
An extended core library for F#.
Stars: ✭ 172 (-2.27%)
Mutual labels:  data-structures
Js Delta Crdts
Delta State-based CRDTs in Javascript
Stars: ✭ 156 (-11.36%)
Mutual labels:  crdt
C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+9644.89%)
Mutual labels:  data-structures
Vue Materialize Datatable
A fancy Materialize CSS datatable VueJS component.
Stars: ✭ 162 (-7.95%)
Mutual labels:  data-structures
Data Structures And Algorithms In Cpp
This repository is in development phase and will soon provide you with c++ code of various data structures and algorithms
Stars: ✭ 176 (+0%)
Mutual labels:  data-structures

CRDT Build Status Coverage Status GoDoc Report card

This is an implementation of Convergent and Commutative Replicated Data Types in Go.

The following state-based counters and sets have currently been implemented.

Counters

G-Counter

A grow-only counter (G-Counter) can only increase in one direction. The increment operation increases the value of current replica by 1. The merge operation combines values from distinct replicas by taking the maximum of each replica.

gcounter := crdt.NewGCounter()

// We can increase the counter monotonically by 1.
gcounter.Inc()

// Twice.
gcounter.Inc()

// Or we can pass in an arbitrary delta to apply as an increment.
gcounter.IncVal(2)

// Should print '4' as the result.
fmt.Println(gcounter.Count())

PN-Counter

A positive-negative counter (PN-Counter) is a CRDT that can both increase or decrease and converge correctly in the light of commutative operations. Both .Inc() and .Dec() operations are allowed and thus negative values are possible as a result.

pncounter := crdt.NewPNCounter()

// We can increase the counter by 1.
pncounter.Inc()

// Or more.
pncounter.Inc(100)

// And similarly decrease its value by 1.
pncounter.Dec()

// Or more.
pncounter.DecVal(100)

// End result should equal '0' here.
fmt.Println(pncounter.Count())

Sets

G-Set

A grow-only (G-Set) set to which element/s can be added to. Removing element from the set is not possible.

obj := "dummy-object"
gset := crdt.NewGSet()

gset.Add(obj)

// Should always print 'true' as `obj` exists in the g-set.
fmt.Println(gset.Contains(obj))

2P-Set

Two-phase set (2P-Set) allows both additions and removals to the set. Internally it comprises of two G-Sets, one to keep track of additions and the other for removals.

obj := "dummy-object"

ppset := crdt.NewTwoPhaseSet()

ppset.Add(obj)

// Remove the object that we just added to the set, emptying it.
ppset.Remove(obj)

// Should return 'false' as the obj doesn't exist within the set.
fmt.Println(ppset.Contains(obj))

LWW-e-Set

Last-write-wins element set (LWW-e-Set) keeps track of element additions and removals but with respect to the timestamp that is attached to each element. Timestamps should be unique and have ordering properties.

obj := "dummy-object"
lwwset := crdt.NewLWWSet()

// Here, we remove the object first before we add it in. For a
// 2P-set the object would be deemed absent from the set. But for
// a LWW-set the object should be present because `.Add()` follows
// `.Remove()`.
lwwset.Remove(obj); lwwset.Add(obj)

// This should print 'true' because of the above.
fmt.Println(lwwset.Contains(obj))

OR-Set

An OR-Set (Observed-Removed-Set) allows deletion and addition of elements similar to LWW-e-Set, but does not surface only the most recent one. Additions are uniquely tracked via tags and an element is considered member of the set if the deleted set consists of all the tags present within additions.

// object 1 == object 2
obj1, obj2 := "dummy-object", "dummy-object"

orset := crdt.NewORSet()

orset.Add(obj1); orset.Add(obj2)

// Removing any one of the above two objects should remove both
// because they contain the same value.
orset.Remove(obj1)

// Should return 'false'.
fmt.Println(orset.Contains(obj2))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].