Skip to main content

linkrs_storage/edge/immutable_csr/
trait_impl.rs

1use linkrs_core::types::{EdgeId, Timestamp, VertexId};
2use linkrs_core::StorageResult;
3
4use super::super::csr_trait::MutableCsrTrait;
5use super::super::{EdgePosition, Nbr};
6use super::pack::frozen_error;
7use super::ImmutableCsr;
8
9impl MutableCsrTrait for ImmutableCsr {
10    fn insert_edge(
11        &mut self,
12        _src_vid: u32,
13        _dst: VertexId,
14        _edge_id: EdgeId,
15        _ts: Timestamp,
16    ) -> StorageResult<()> {
17        Err(frozen_error())
18    }
19
20    fn delete_edge(
21        &mut self,
22        _src_vid: u32,
23        _edge_id: EdgeId,
24        _ts: Timestamp,
25    ) -> StorageResult<bool> {
26        Err(frozen_error())
27    }
28
29    fn delete_edge_by_dst(&mut self, _src_vid: u32, _dst: VertexId, _ts: Timestamp) -> usize {
30        0
31    }
32
33    fn locate_edge(&self, src_vid: u32, edge_id: EdgeId) -> Option<(EdgePosition, Nbr)> {
34        ImmutableCsr::locate_edge(self, src_vid, edge_id)
35    }
36
37    fn delete_edge_at_position(
38        &mut self,
39        _src_vid: u32,
40        _position: EdgePosition,
41        _expected: EdgeId,
42        _ts: Timestamp,
43    ) -> StorageResult<bool> {
44        Err(frozen_error())
45    }
46
47    fn revert_delete_at_position(
48        &mut self,
49        _src_vid: u32,
50        _position: EdgePosition,
51        _expected: EdgeId,
52        _ts: Timestamp,
53    ) -> bool {
54        false
55    }
56
57    fn delete_edge_by_offset(
58        &mut self,
59        _src_vid: u32,
60        _offset: i32,
61        _ts: Timestamp,
62    ) -> StorageResult<bool> {
63        Err(frozen_error())
64    }
65
66    fn revert_delete_by_offset(&mut self, _src_vid: u32, _offset: i32, _ts: Timestamp) -> bool {
67        false
68    }
69
70    fn nbr_at_offset(&self, src_vid: u32, offset: i32) -> Option<Nbr> {
71        ImmutableCsr::nbr_at_offset(self, src_vid, offset)
72    }
73
74    fn get_edge_physical(&self, src_vid: u32, dst: VertexId) -> Option<Nbr> {
75        ImmutableCsr::get_edge_physical(self, src_vid, dst)
76    }
77
78    fn physical_edges_of(&self, src_vid: u32) -> Vec<Nbr> {
79        ImmutableCsr::physical_edges_of(self, src_vid)
80    }
81
82    fn fill_physical_into(&self, src_vid: u32, out: &mut Vec<Nbr>) {
83        ImmutableCsr::fill_physical_into(self, src_vid, out);
84    }
85
86    fn has_physical_entries(&self, vid: u32) -> bool {
87        ImmutableCsr::has_physical_entries(self, vid)
88    }
89
90    fn primary_contains(&self, src_vid: u32, edge_id: EdgeId) -> bool {
91        ImmutableCsr::primary_contains(self, src_vid, edge_id)
92    }
93
94    fn rollback_insert(&mut self, _src_vid: u32, _edge_id: EdgeId) -> bool {
95        false
96    }
97
98    fn revert_delete_by_edge_id(
99        &mut self,
100        _src_vid: u32,
101        _edge_id: EdgeId,
102        _ts: Timestamp,
103    ) -> bool {
104        false
105    }
106
107    fn get_edge(&self, src_vid: u32, dst: VertexId, ts: Timestamp) -> Option<Nbr> {
108        ImmutableCsr::get_edge(self, src_vid, dst, ts)
109    }
110
111    fn edges_of(&self, src_vid: u32, ts: Timestamp) -> Vec<Nbr> {
112        ImmutableCsr::edges_of(self, src_vid, ts)
113    }
114
115    fn compact_vertex_with_reporting(
116        &mut self,
117        _vid: u32,
118        _cutoff: Timestamp,
119        _on_edge_removed: &mut dyn FnMut(EdgeId, Timestamp),
120    ) -> usize {
121        // Single-row frozen reclaim is prohibited: production frozen reclaim
122        // uses the group paths (`compact_with_cutoff`, `compact_rows_batched`
123        // or `compact_group_with_reporting`) with one linear pass.
124        0
125    }
126
127    fn reclaimable_count(&self, vid: u32, cutoff: Timestamp) -> usize {
128        ImmutableCsr::reclaimable_count(self, vid, cutoff)
129    }
130
131    fn vertex_needs_compact(&self, vid: u32, cutoff: Timestamp) -> bool {
132        ImmutableCsr::reclaimable_count(self, vid, cutoff) > 0
133    }
134
135    fn vertex_census(&self, vid: u32) -> (usize, usize, usize) {
136        ImmutableCsr::vertex_census(self, vid)
137    }
138
139    fn vertex_reclaim_probe(&self, vid: u32, cutoff: Timestamp) -> (usize, usize) {
140        let (_, dead, _) = ImmutableCsr::vertex_census(self, vid);
141        (dead, ImmutableCsr::reclaimable_count(self, vid, cutoff))
142    }
143
144    fn row_gap(&self, _vid: u32) -> usize {
145        0
146    }
147
148    fn row_density(&self, _vid: u32) -> f32 {
149        1.0
150    }
151
152    fn rebalance_row(&mut self, _vid: u32) -> bool {
153        true
154    }
155
156    fn used_memory_size(&self) -> usize {
157        ImmutableCsr::used_memory_size(self)
158    }
159}