Serve side: what `record` on `view` reads for `inodes`, with the content of every vertex a visible change introduced.
(
&self,
view: &str,
inodes: &[u64],
)
| 496 | /// Serve side: what `record` on `view` reads for `inodes`, with the |
| 497 | /// content of every vertex a visible change introduced. |
| 498 | pub fn export_sandbox_slice( |
| 499 | &self, |
| 500 | view: &str, |
| 501 | inodes: &[u64], |
| 502 | ) -> Result<SandboxSlice, RepositoryError> { |
| 503 | let txn = self.pristine.read_txn().map_err(db)?; |
| 504 | let state = |
| 505 | txn.get_view(view) |
| 506 | .map_err(db)? |
| 507 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 508 | name: view.to_string(), |
| 509 | })?; |
| 510 | let visible: BTreeSet<u64> = self.sandbox_visible(&txn, &state)?.into_iter().collect(); |
| 511 | // Only files the view has: an inode another view introduced is not |
| 512 | // this sandbox's to read. |
| 513 | let mut on_view = Vec::with_capacity(inodes.len()); |
| 514 | for &inode in inodes { |
| 515 | let position = txn |
| 516 | .inode_position(atomic_core::types::Inode::new(inode)) |
| 517 | .map_err(db)?; |
| 518 | if position.is_some_and(|p| p.change.is_root() || visible.contains(&p.change.get())) { |
| 519 | on_view.push(inode); |
| 520 | } |
| 521 | } |
| 522 | let rows = txn |
| 523 | .export_graph_slice(&on_view, state.id, &visible) |
| 524 | .map_err(db)?; |
| 525 | let mut spans = Vec::new(); |
| 526 | for (key, _) in &rows.graph { |
| 527 | let (change, start, end) = decode_vertex(key); |
| 528 | if start >= end || !visible.contains(&change) { |
| 529 | continue; |
| 530 | } |
| 531 | let Some(hash) = txn.get_external(NodeId::new(change)).map_err(db)? else { |
| 532 | continue; |
| 533 | }; |
| 534 | let node = GraphNode { |
| 535 | change: NodeId::new(change), |
| 536 | start: atomic_core::types::ChangePosition::new(start), |
| 537 | end: atomic_core::types::ChangePosition::new(end), |
| 538 | }; |
| 539 | let mut bytes = vec![0u8; (end - start) as usize]; |
| 540 | self.change_store |
| 541 | .get_contents(|_| Some(hash), node, &mut bytes) |
| 542 | .map_err(db)?; |
| 543 | spans.push(SpanBytes { |
| 544 | change: hash, |
| 545 | start, |
| 546 | bytes, |
| 547 | }); |
| 548 | } |
| 549 | Ok(SandboxSlice { rows, spans }) |
| 550 | } |
| 551 | |
| 552 | /// Serve side: the view's skeleton as it is right now, with nothing of it |
| 553 | /// applied. What a sandbox needs after being told its base state is stale: |