File tree Expand file tree Collapse file tree 4 files changed +17
-8
lines changed Expand file tree Collapse file tree 4 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ use std::{
2929 sync:: { Arc , MutexGuard } ,
3030} ;
3131
32+ /// Iterator value guard
3233pub struct Guard {
3334 tree : crate :: BlobTree ,
3435 version : Version ,
@@ -39,7 +40,7 @@ impl IterGuard for Guard {
3940 fn into_inner_if (
4041 self ,
4142 pred : impl Fn ( & UserKey ) -> bool ,
42- ) -> crate :: Result < Option < crate :: KvPair > > {
43+ ) -> crate :: Result < ( UserKey , Option < UserValue > ) > {
4344 let kv = self . kv ?;
4445
4546 if pred ( & kv. key . user_key ) {
@@ -51,9 +52,9 @@ impl IterGuard for Guard {
5152 & self . version ,
5253 kv,
5354 )
54- . map ( Some )
55+ . map ( | ( k , v ) | ( k , Some ( v ) ) )
5556 } else {
56- Ok ( None )
57+ Ok ( ( kv . key . user_key , None ) )
5758 }
5859 }
5960
Original file line number Diff line number Diff line change @@ -14,7 +14,10 @@ pub trait IterGuard {
1414 /// # Errors
1515 ///
1616 /// Will return `Err` if an IO error occurs.
17- fn into_inner_if ( self , pred : impl Fn ( & UserKey ) -> bool ) -> crate :: Result < Option < KvPair > > ;
17+ fn into_inner_if (
18+ self ,
19+ pred : impl Fn ( & UserKey ) -> bool ,
20+ ) -> crate :: Result < ( UserKey , Option < UserValue > ) > ;
1821
1922 /// Accesses the key-value pair.
2023 ///
Original file line number Diff line number Diff line change @@ -162,14 +162,15 @@ pub type KvPair = (UserKey, UserValue);
162162
163163#[ doc( hidden) ]
164164pub use {
165- blob_tree:: handle:: BlobIndirection ,
165+ blob_tree:: { handle:: BlobIndirection , Guard as BlobGuard } ,
166166 checksum:: Checksum ,
167167 key_range:: KeyRange ,
168168 merge:: BoxedIterator ,
169169 slice:: Builder ,
170170 table:: { GlobalTableId , Table , TableId } ,
171171 tree:: ingest:: Ingestion ,
172172 tree:: inner:: TreeId ,
173+ tree:: Guard as StandardGuard ,
173174 value:: InternalValue ,
174175} ;
175176
Original file line number Diff line number Diff line change @@ -33,16 +33,20 @@ use std::{
3333#[ cfg( feature = "metrics" ) ]
3434use crate :: metrics:: Metrics ;
3535
36+ /// Iterator value guard
3637pub struct Guard ( crate :: Result < ( UserKey , UserValue ) > ) ;
3738
3839impl IterGuard for Guard {
39- fn into_inner_if ( self , pred : impl Fn ( & UserKey ) -> bool ) -> crate :: Result < Option < KvPair > > {
40+ fn into_inner_if (
41+ self ,
42+ pred : impl Fn ( & UserKey ) -> bool ,
43+ ) -> crate :: Result < ( UserKey , Option < UserValue > ) > {
4044 let ( k, v) = self . 0 ?;
4145
4246 if pred ( & k) {
43- Ok ( Some ( ( k, v) ) )
47+ Ok ( ( k, Some ( v) ) )
4448 } else {
45- Ok ( None )
49+ Ok ( ( k , None ) )
4650 }
4751 }
4852
You can’t perform that action at this time.
0 commit comments