Skip to main content

nodedb_graph/csr/
slice_accessors.rs

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