Enumerate `(collection, src, label, dst)` tuples for every base edge in this tenant whose latest version touches `node` as src or dst and is not a sentinel.
(&self, tid: TenantId, node: &str)
| 32 | /// in this tenant whose latest version touches `node` as src or dst and |
| 33 | /// is not a sentinel. |
| 34 | fn live_bases_touching_node(&self, tid: TenantId, node: &str) -> crate::Result<Vec<BaseKey>> { |
| 35 | let t = tid.as_u64(); |
| 36 | let read_txn = self |
| 37 | .db |
| 38 | .begin_read() |
| 39 | .map_err(|e| redb_err("begin_read", e))?; |
| 40 | let table = read_txn |
| 41 | .open_table(EDGES) |
| 42 | .map_err(|e| redb_err("open edges", e))?; |
| 43 | |
| 44 | let mut latest: HashMap<BaseKey, (i64, bool)> = HashMap::new(); |
| 45 | let range = table |
| 46 | .range((t, "")..(t + 1, "")) |
| 47 | .map_err(|e| redb_err("iter", e))?; |
| 48 | for entry in range { |
| 49 | let (k, v) = entry.map_err(|e| redb_err("iter entry", e))?; |
| 50 | let composite = k.value().1; |
| 51 | let Some((coll, src, label, dst, sys)) = parse_versioned_edge_key(composite) else { |
| 52 | continue; |
| 53 | }; |
| 54 | if src != node && dst != node { |
| 55 | continue; |
| 56 | } |
| 57 | let base = ( |
| 58 | coll.to_string(), |
| 59 | src.to_string(), |
| 60 | label.to_string(), |
| 61 | dst.to_string(), |
| 62 | ); |
| 63 | let is_sent = is_sentinel(v.value()); |
| 64 | latest |
| 65 | .entry(base) |
| 66 | .and_modify(|(cur, cur_sent)| { |
| 67 | if sys > *cur { |
| 68 | *cur = sys; |
| 69 | *cur_sent = is_sent; |
| 70 | } |
| 71 | }) |
| 72 | .or_insert((sys, is_sent)); |
| 73 | } |
| 74 | Ok(latest |
| 75 | .into_iter() |
| 76 | .filter_map(|(base, (_sys, is_sent))| if is_sent { None } else { Some(base) }) |
| 77 | .collect()) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | #[cfg(test)] |
no test coverage detected