15
15
use std:: borrow:: Borrow ;
16
16
use std:: io;
17
17
use std:: ops:: RangeBounds ;
18
- use std:: sync:: Arc ;
19
18
19
+ use crate :: sm_v002:: leveled_store:: immutable:: Immutable ;
20
20
use crate :: sm_v002:: leveled_store:: level:: Level ;
21
21
use crate :: sm_v002:: leveled_store:: map_api:: compacted_get;
22
22
use crate :: sm_v002:: leveled_store:: map_api:: compacted_range;
@@ -28,20 +28,20 @@ use crate::sm_v002::marked::Marked;
28
28
29
29
/// A readonly leveled map that owns the data.
30
30
#[ derive( Debug , Default , Clone ) ]
31
- pub struct StaticLevels {
31
+ pub struct ImmutableLevels {
32
32
/// From oldest to newest, i.e., levels[0] is the oldest
33
- levels : Vec < Arc < Level > > ,
33
+ levels : Vec < Immutable > ,
34
34
}
35
35
36
- impl StaticLevels {
37
- pub ( in crate :: sm_v002) fn new ( levels : impl IntoIterator < Item = Arc < Level > > ) -> Self {
36
+ impl ImmutableLevels {
37
+ pub ( in crate :: sm_v002) fn new ( levels : impl IntoIterator < Item = Immutable > ) -> Self {
38
38
Self {
39
39
levels : levels. into_iter ( ) . collect ( ) ,
40
40
}
41
41
}
42
42
43
43
/// Return an iterator of all Arc of levels from newest to oldest.
44
- pub ( in crate :: sm_v002) fn iter_arc_levels ( & self ) -> impl Iterator < Item = & Arc < Level > > {
44
+ pub ( in crate :: sm_v002) fn iter_immutable_levels ( & self ) -> impl Iterator < Item = & Immutable > {
45
45
self . levels . iter ( ) . rev ( )
46
46
}
47
47
@@ -50,11 +50,11 @@ impl StaticLevels {
50
50
self . levels . iter ( ) . map ( |x| x. as_ref ( ) ) . rev ( )
51
51
}
52
52
53
- pub ( in crate :: sm_v002) fn newest ( & self ) -> Option < & Arc < Level > > {
53
+ pub ( in crate :: sm_v002) fn newest ( & self ) -> Option < & Immutable > {
54
54
self . levels . last ( )
55
55
}
56
56
57
- pub ( in crate :: sm_v002) fn push ( & mut self , level : Arc < Level > ) {
57
+ pub ( in crate :: sm_v002) fn push ( & mut self , level : Immutable ) {
58
58
self . levels . push ( level) ;
59
59
}
60
60
@@ -69,24 +69,24 @@ impl StaticLevels {
69
69
}
70
70
71
71
#[ async_trait:: async_trait]
72
- impl < K > MapApiRO < K > for StaticLevels
72
+ impl < K > MapApiRO < K > for ImmutableLevels
73
73
where
74
74
K : MapKey ,
75
75
Level : MapApiRO < K > ,
76
- Arc < Level > : MapApiRO < K > ,
76
+ Immutable : MapApiRO < K > ,
77
77
{
78
78
async fn get < Q > ( & self , key : & Q ) -> Result < Marked < K :: V > , io:: Error >
79
79
where
80
80
K : Borrow < Q > ,
81
81
Q : Ord + Send + Sync + ?Sized ,
82
82
{
83
- let levels = self . iter_arc_levels ( ) ;
83
+ let levels = self . iter_immutable_levels ( ) ;
84
84
compacted_get ( key, levels) . await
85
85
}
86
86
87
87
async fn range < R > ( & self , range : R ) -> Result < KVResultStream < K > , io:: Error >
88
88
where R : RangeBounds < K > + Clone + Send + Sync + ' static {
89
- let levels = self . iter_arc_levels ( ) ;
89
+ let levels = self . iter_immutable_levels ( ) ;
90
90
compacted_range :: < _ , _ , _ , Level > ( range, None , levels) . await
91
91
}
92
92
}
0 commit comments