diff options
author | Alex <alex@adnab.me> | 2023-01-26 16:19:04 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-01-26 16:19:04 +0000 |
commit | 246f7468cd18c8ef4f3c0c4c209853cd2500cc76 (patch) | |
tree | 6e5f9ddd2159ba5396cc441a82b8240c4306323f /src/model/k2v/item_table.rs | |
parent | 611792ddcf86f0a728e22abaa6e172d3679d5ca6 (diff) | |
parent | 1dff62564fdda392a97986dca55232f30a1f4234 (diff) | |
download | garage-246f7468cd18c8ef4f3c0c4c209853cd2500cc76.tar.gz garage-246f7468cd18c8ef4f3c0c4c209853cd2500cc76.zip |
Merge pull request 'K2V PollRange, version 2' (#471) from k2v-watch-range-2 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/471
Diffstat (limited to 'src/model/k2v/item_table.rs')
-rw-r--r-- | src/model/k2v/item_table.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/model/k2v/item_table.rs b/src/model/k2v/item_table.rs index 9955a9cd..28646f37 100644 --- a/src/model/k2v/item_table.rs +++ b/src/model/k2v/item_table.rs @@ -11,7 +11,7 @@ use garage_table::*; use crate::index_counter::*; use crate::k2v::causality::*; -use crate::k2v::poll::*; +use crate::k2v::sub::*; pub const ENTRIES: &str = "entries"; pub const CONFLICTS: &str = "conflicts"; @@ -73,7 +73,8 @@ impl K2VItem { this_node: Uuid, context: &Option<CausalContext>, new_value: DvvsValue, - ) { + node_ts: u64, + ) -> u64 { if let Some(context) = context { for (node, t_discard) in context.vector_clock.iter() { if let Some(e) = self.items.get_mut(node) { @@ -98,12 +99,14 @@ impl K2VItem { values: vec![], }); let t_prev = e.max_time(); - e.values.push((t_prev + 1, new_value)); + let t_new = std::cmp::max(t_prev + 1, node_ts + 1); + e.values.push((t_new, new_value)); + t_new } /// Extract the causality context of a K2V Item pub fn causal_context(&self) -> CausalContext { - let mut cc = CausalContext::new_empty(); + let mut cc = CausalContext::new(); for (node, ent) in self.items.iter() { cc.vector_clock.insert(*node, ent.max_time()); } |