aboutsummaryrefslogtreecommitdiff
path: root/src/table/crdt
diff options
context:
space:
mode:
Diffstat (limited to 'src/table/crdt')
-rw-r--r--src/table/crdt/bool.rs2
-rw-r--r--src/table/crdt/crdt.rs14
-rw-r--r--src/table/crdt/lww.rs10
-rw-r--r--src/table/crdt/lww_map.rs14
-rw-r--r--src/table/crdt/map.rs8
5 files changed, 24 insertions, 24 deletions
diff --git a/src/table/crdt/bool.rs b/src/table/crdt/bool.rs
index 1989c92e..53af8f82 100644
--- a/src/table/crdt/bool.rs
+++ b/src/table/crdt/bool.rs
@@ -27,7 +27,7 @@ impl From<bool> for Bool {
}
}
-impl CRDT for Bool {
+impl Crdt for Bool {
fn merge(&mut self, other: &Self) {
self.0 = self.0 || other.0;
}
diff --git a/src/table/crdt/crdt.rs b/src/table/crdt/crdt.rs
index 7abe8ba9..a8f1b9aa 100644
--- a/src/table/crdt/crdt.rs
+++ b/src/table/crdt/crdt.rs
@@ -18,7 +18,7 @@ use garage_util::data::*;
/// Moreover, the relationship `≥` defined by `a ≥ b ⇔ ∃c. a = b ⊔ c` must be a partial order.
/// This implies a few properties such as: if `a ⊔ b ≠ a`, then there is no `c` such that `(a ⊔ b) ⊔ c = a`,
/// as this would imply a cycle in the partial order.
-pub trait CRDT {
+pub trait Crdt {
/// Merge the two datastructures according to the CRDT rules.
/// `self` is modified to contain the merged CRDT value. `other` is not modified.
///
@@ -31,16 +31,16 @@ pub trait CRDT {
/// All types that implement `Ord` (a total order) can also implement a trivial CRDT
/// defined by the merge rule: `a ⊔ b = max(a, b)`. Implement this trait for your type
/// to enable this behavior.
-pub trait AutoCRDT: Ord + Clone + std::fmt::Debug {
+pub trait AutoCrdt: Ord + Clone + std::fmt::Debug {
/// WARN_IF_DIFFERENT: emit a warning when values differ. Set this to true if
/// different values in your application should never happen. Set this to false
/// if you are actually relying on the semantics of `a ⊔ b = max(a, b)`.
const WARN_IF_DIFFERENT: bool;
}
-impl<T> CRDT for T
+impl<T> Crdt for T
where
- T: AutoCRDT,
+ T: AutoCrdt,
{
fn merge(&mut self, other: &Self) {
if Self::WARN_IF_DIFFERENT && self != other {
@@ -58,14 +58,14 @@ where
}
}
-impl AutoCRDT for String {
+impl AutoCrdt for String {
const WARN_IF_DIFFERENT: bool = true;
}
-impl AutoCRDT for bool {
+impl AutoCrdt for bool {
const WARN_IF_DIFFERENT: bool = true;
}
-impl AutoCRDT for FixedBytes32 {
+impl AutoCrdt for FixedBytes32 {
const WARN_IF_DIFFERENT: bool = true;
}
diff --git a/src/table/crdt/lww.rs b/src/table/crdt/lww.rs
index 3b1b2406..be197d88 100644
--- a/src/table/crdt/lww.rs
+++ b/src/table/crdt/lww.rs
@@ -36,14 +36,14 @@ use crate::crdt::crdt::*;
/// This scheme is used by AWS S3 or Soundcloud and often without knowing
/// in enterprise when reconciliating databases with ad-hoc scripts.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
-pub struct LWW<T> {
+pub struct Lww<T> {
ts: u64,
v: T,
}
-impl<T> LWW<T>
+impl<T> Lww<T>
where
- T: CRDT,
+ T: Crdt,
{
/// Creates a new CRDT
///
@@ -99,9 +99,9 @@ where
}
}
-impl<T> CRDT for LWW<T>
+impl<T> Crdt for Lww<T>
where
- T: Clone + CRDT,
+ T: Clone + Crdt,
{
fn merge(&mut self, other: &Self) {
if other.ts > self.ts {
diff --git a/src/table/crdt/lww_map.rs b/src/table/crdt/lww_map.rs
index 4ed26809..36bbf667 100644
--- a/src/table/crdt/lww_map.rs
+++ b/src/table/crdt/lww_map.rs
@@ -22,14 +22,14 @@ use crate::crdt::crdt::*;
/// the serialization cost `O(n)` would still have to be paid at each modification, so we are
/// actually not losing anything here.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
-pub struct LWWMap<K, V> {
+pub struct LwwMap<K, V> {
vals: Vec<(K, u64, V)>,
}
-impl<K, V> LWWMap<K, V>
+impl<K, V> LwwMap<K, V>
where
K: Ord,
- V: CRDT,
+ V: Crdt,
{
/// Create a new empty map CRDT
pub fn new() -> Self {
@@ -125,10 +125,10 @@ where
}
}
-impl<K, V> CRDT for LWWMap<K, V>
+impl<K, V> Crdt for LwwMap<K, V>
where
K: Clone + Ord,
- V: Clone + CRDT,
+ V: Clone + Crdt,
{
fn merge(&mut self, other: &Self) {
for (k, ts2, v2) in other.vals.iter() {
@@ -150,10 +150,10 @@ where
}
}
-impl<K, V> Default for LWWMap<K, V>
+impl<K, V> Default for LwwMap<K, V>
where
K: Ord,
- V: CRDT,
+ V: Crdt,
{
fn default() -> Self {
Self::new()
diff --git a/src/table/crdt/map.rs b/src/table/crdt/map.rs
index c4dd1613..e2aee40a 100644
--- a/src/table/crdt/map.rs
+++ b/src/table/crdt/map.rs
@@ -22,7 +22,7 @@ pub struct Map<K, V> {
impl<K, V> Map<K, V>
where
K: Clone + Ord,
- V: Clone + CRDT,
+ V: Clone + Crdt,
{
/// Create a new empty map CRDT
pub fn new() -> Self {
@@ -69,10 +69,10 @@ where
}
}
-impl<K, V> CRDT for Map<K, V>
+impl<K, V> Crdt for Map<K, V>
where
K: Clone + Ord,
- V: Clone + CRDT,
+ V: Clone + Crdt,
{
fn merge(&mut self, other: &Self) {
for (k, v2) in other.vals.iter() {
@@ -91,7 +91,7 @@ where
impl<K, V> Default for Map<K, V>
where
K: Clone + Ord,
- V: Clone + CRDT,
+ V: Clone + Crdt,
{
fn default() -> Self {
Self::new()