@@ -125,13 +125,21 @@ pub trait HotKvRead {
125125 ///
126126 /// # Returns
127127 ///
128- /// A vector of `Option<T::Value>`, where each element corresponds to the
129- /// value for the respective key in the input iterator. If a key does not
130- /// exist in the table, the corresponding element will be `None`.
128+ /// A vector of `(&'a T::Key, Option<T::Value>)`, where each element
129+ /// corresponds to the value for the respective key in the input iterator.
130+ /// If a key does not exist in the table, the corresponding element will be
131+ /// `None`.
132+ ///
133+ /// Implementations ARE NOT required to preserve the order of the input
134+ /// keys in the output vector. Users should not rely on any specific
135+ /// ordering.
131136 ///
132137 /// If any error occurs during retrieval or deserialization, the entire
133138 /// operation will return an error.
134- fn get_many < ' a , T , I > ( & self , keys : I ) -> Result < Vec < Option < T :: Value > > , Self :: Error >
139+ fn get_many < ' a , T , I > (
140+ & self ,
141+ keys : I ,
142+ ) -> Result < Vec < ( & ' a T :: Key , Option < T :: Value > ) > , Self :: Error >
135143 where
136144 T :: Key : ' a ,
137145 T : Table ,
@@ -140,10 +148,11 @@ pub trait HotKvRead {
140148 let mut key_buf = [ 0u8 ; MAX_KEY_SIZE ] ;
141149
142150 keys. into_iter ( )
143- . map ( |key| self . raw_get ( T :: NAME , key. encode_key ( & mut key_buf) ) )
144- . map ( |maybe_val| {
151+ . map ( |key| ( key , self . raw_get ( T :: NAME , key. encode_key ( & mut key_buf) ) ) )
152+ . map ( |( key , maybe_val) | {
145153 maybe_val
146154 . and_then ( |val| ValSer :: maybe_decode_value ( val. as_deref ( ) ) . map_err ( Into :: into) )
155+ . map ( |res| ( key, res) )
147156 } )
148157 . collect ( )
149158 }
0 commit comments