Skip to main content

nodedb_graph/csr/
slice_accessors.rs

1//! Slice accessors for the CSR index.
2//!
3//! Provides read-only access to the underlying arrays for OLAP snapshot
4//! cloning and other consumers that need direct array access.
5
6use std::collections::HashMap;
7
8use super::index::CsrIndex;
9
10impl CsrIndex {
11    /// Node-to-ID mapping (for snapshot cloning).
12    pub fn node_to_id_map(&self) -> &HashMap<String, u32> {
13        &self.node_to_id
14    }
15
16    /// ID-to-node list (for snapshot cloning).
17    pub fn id_to_node_list(&self) -> &[String] {
18        &self.id_to_node
19    }
20
21    /// Label-to-ID mapping (for snapshot cloning).
22    pub fn label_to_id_map(&self) -> &HashMap<String, u32> {
23        &self.label_to_id
24    }
25
26    /// ID-to-label list (for snapshot cloning).
27    pub fn id_to_label_list(&self) -> &[String] {
28        &self.id_to_label
29    }
30
31    /// Outbound offset array slice.
32    pub fn out_offsets_slice(&self) -> &[u32] {
33        &self.out_offsets
34    }
35
36    /// Outbound target array slice.
37    pub fn out_targets_slice(&self) -> &[u32] {
38        &self.out_targets
39    }
40
41    /// Outbound label array slice.
42    pub fn out_labels_slice(&self) -> &[u32] {
43        &self.out_labels
44    }
45
46    /// Outbound weight array slice (None if unweighted).
47    pub fn out_weights_slice(&self) -> Option<&[f64]> {
48        self.out_weights.as_deref()
49    }
50
51    /// Inbound offset array slice.
52    pub fn in_offsets_slice(&self) -> &[u32] {
53        &self.in_offsets
54    }
55
56    /// Inbound target array slice.
57    pub fn in_targets_slice(&self) -> &[u32] {
58        &self.in_targets
59    }
60
61    /// Inbound label array slice.
62    pub fn in_labels_slice(&self) -> &[u32] {
63        &self.in_labels
64    }
65
66    /// Inbound weight array slice (None if unweighted).
67    pub fn in_weights_slice(&self) -> Option<&[f64]> {
68        self.in_weights.as_deref()
69    }
70}