Merge branch 'main' into 1686a/s3-redirects

This commit is contained in:
trinity-1686a
2025-02-08 16:01:11 +01:00
149 changed files with 2387 additions and 8944 deletions
+2 -2
View File
@@ -33,8 +33,8 @@ pub trait Crdt {
/// arises very often, for example with a Lww or a LwwMap: the value type has to be a CRDT so that
/// we have a rule for what to do when timestamps aren't enough to disambiguate (in a distributed
/// system, anything can happen!), and with AutoCrdt the rule is to make an arbitrary (but
/// determinstic) choice between the two. When using an Option<T> instead with this impl, ambiguity
/// cases are explicitely stored as None, which allows us to detect the ambiguity and handle it in
/// deterministic) choice between the two. When using an Option<T> instead with this impl, ambiguity
/// cases are explicitly stored as None, which allows us to detect the ambiguity and handle it in
/// the way we want. (this can only work if we are happy with losing the value when an ambiguity
/// arises)
impl<T> Crdt for Option<T>
+6 -6
View File
@@ -16,7 +16,7 @@ use crate::crdt::crdt::*;
/// In our case, we add the constraint that the value that is wrapped inside the LWW CRDT must
/// itself be a CRDT: in the case when the timestamp does not allow us to decide on which value to
/// keep, the merge rule of the inner CRDT is applied on the wrapped values. (Note that all types
/// that implement the `Ord` trait get a default CRDT implemetnation that keeps the maximum value.
/// that implement the `Ord` trait get a default CRDT implementation that keeps the maximum value.
/// This enables us to use LWW directly with primitive data types such as numbers or strings. It is
/// generally desirable in this case to never explicitly produce LWW values with the same timestamp
/// but different inner values, as the rule to keep the maximum value isn't generally the desired
@@ -28,9 +28,9 @@ use crate::crdt::crdt::*;
///
/// Given that clocks are not too desynchronized, this assumption
/// is enough for most cases, as there is few chance that two humans
/// coordonate themself faster than the time difference between two NTP servers.
/// coordinate themself faster than the time difference between two NTP servers.
///
/// As a more concret example, let's suppose you want to upload a file
/// As a more concrete example, let's suppose you want to upload a file
/// with the same key (path) in the same bucket at the very same time.
/// For each request, the file will be timestamped by the receiving server
/// and may differ from what you observed with your atomic clock!
@@ -94,16 +94,16 @@ where
&self.v
}
/// Take the value inside the CRDT (discards the timesamp)
/// Take the value inside the CRDT (discards the timestamp)
pub fn take(self) -> T {
self.v
}
/// Get a mutable reference to the CRDT's value
///
/// This is usefull to mutate the inside value without changing the LWW timestamp.
/// This is useful to mutate the inside value without changing the LWW timestamp.
/// When such mutation is done, the merge between two LWW values is done using the inner
/// CRDT's merge operation. This is usefull in the case where the inner CRDT is a large
/// CRDT's merge operation. This is useful in the case where the inner CRDT is a large
/// data type, such as a map, and we only want to change a single item in the map.
/// To do this, we can produce a "CRDT delta", i.e. a LWW that contains only the modification.
/// This delta consists in a LWW with the same timestamp, and the map
+2 -2
View File
@@ -109,7 +109,7 @@ where
}
/// Takes all of the values of the map and returns them. The current map is reset to the
/// empty map. This is very usefull to produce in-place a new map that contains only a delta
/// empty map. This is very useful to produce in-place a new map that contains only a delta
/// that modifies a certain value:
///
/// ```ignore
@@ -162,7 +162,7 @@ where
}
}
/// Gets a reference to all of the items, as a slice. Usefull to iterate on all map values.
/// Gets a reference to all of the items, as a slice. Useful to iterate on all map values.
/// In most case you will want to ignore the timestamp (second item of the tuple).
pub fn items(&self) -> &[(K, u64, V)] {
&self.vals[..]
+1 -1
View File
@@ -57,7 +57,7 @@ where
Err(_) => None,
}
}
/// Gets a reference to all of the items, as a slice. Usefull to iterate on all map values.
/// Gets a reference to all of the items, as a slice. Useful to iterate on all map values.
pub fn items(&self) -> &[(K, V)] {
&self.vals[..]
}