The view's tree and ids. `live` is the view's tree as rendered — every path it has and the inode there, which is what TREE would hold with the view checked out (TREE itself is the checked-out view's). REV_TREE / INODES / DIRECTORIES come for every inode whose position a visible change introduced, and the id rows for every visible change.
(
&self,
visible: &BTreeSet<u64>,
live: &BTreeMap<u64, String>,
)
| 158 | /// REV_TREE / INODES / DIRECTORIES come for every inode whose position a |
| 159 | /// visible change introduced, and the id rows for every visible change. |
| 160 | pub fn export_skeleton( |
| 161 | &self, |
| 162 | visible: &BTreeSet<u64>, |
| 163 | live: &BTreeMap<u64, String>, |
| 164 | ) -> PristineResult<GraphSlice> { |
| 165 | let mut out = GraphSlice::default(); |
| 166 | let inodes = self.txn.open_table(INODES)?; |
| 167 | let mut kept = BTreeSet::new(); |
| 168 | for row in inodes.iter()? { |
| 169 | let (k, v) = row?; |
| 170 | let (change, _) = decode_position(v.value()); |
| 171 | if change == 0 || visible.contains(&change) { |
| 172 | kept.insert(k.value()); |
| 173 | out.inodes.push((k.value(), *v.value())); |
| 174 | } |
| 175 | } |
| 176 | // TREE/REV_TREE describe the rendered cache, not the host's currently |
| 177 | // selected view. Historical/deleted identities remain in INODES/GRAPH. |
| 178 | let mut rev_tree: BTreeMap<u64, String> = BTreeMap::new(); |
| 179 | // Implicit directories render with no inode of their own (0): only |
| 180 | // what the repository tracks goes in the tree. |
| 181 | for (inode, path) in live |
| 182 | .iter() |
| 183 | .filter(|(inode, _)| **inode != 0 && kept.contains(inode)) |
| 184 | { |
| 185 | rev_tree.insert(*inode, path.clone()); |
| 186 | out.tree.push((path.clone(), *inode)); |
| 187 | } |
| 188 | out.rev_tree = rev_tree.into_iter().collect(); |
| 189 | let directories = self.txn.open_table(DIRECTORIES)?; |
| 190 | for row in directories.iter()? { |
| 191 | let (k, v) = row?; |
| 192 | if kept.contains(&k.value()) { |
| 193 | out.directories.push((k.value(), v.value())); |
| 194 | } |
| 195 | } |
| 196 | out.ids = self.id_rows(visible.iter().copied())?; |
| 197 | Ok(out) |
| 198 | } |
| 199 | |
| 200 | /// The rows `record` reads for `inodes`, on the view `view_id`. |
| 201 | /// `visible` is the view's change set, and it bounds the CRDT rows as well |