@@ -297,32 +297,6 @@ impl Segment {
297
297
) ) ;
298
298
reader. lo_initialized = true ;
299
299
300
- let iter = reader. filter_map ( move |entry| {
301
- let entry = fail_iter ! ( entry) ;
302
-
303
- // NOTE: We are past the searched key, so we can immediately return None
304
- if & * entry. key . user_key > key {
305
- None
306
- } else {
307
- // Check for seqno if needed
308
- if let Some ( seqno) = seqno {
309
- if entry. key . seqno < seqno {
310
- Some ( Ok ( InternalValue {
311
- key : entry. key . clone ( ) ,
312
- value : entry. value ,
313
- } ) )
314
- } else {
315
- None
316
- }
317
- } else {
318
- Some ( Ok ( InternalValue {
319
- key : entry. key . clone ( ) ,
320
- value : entry. value ,
321
- } ) )
322
- }
323
- }
324
- } ) ;
325
-
326
300
// NOTE: For finding a specific seqno,
327
301
// we need to use a reader
328
302
// because nothing really prevents the version
@@ -340,7 +314,30 @@ impl Segment {
340
314
// unfortunately is in the next block
341
315
//
342
316
// Also because of weak tombstones, we may have to look further than the first item we encounter
343
- MvccStream :: new ( iter) . next ( ) . transpose ( )
317
+ let reader = reader. filter ( |x| {
318
+ match x {
319
+ Ok ( entry) => {
320
+ // Check for seqno if needed
321
+ if let Some ( seqno) = seqno {
322
+ entry. key . seqno < seqno
323
+ } else {
324
+ true
325
+ }
326
+ }
327
+ Err ( _) => true ,
328
+ }
329
+ } ) ;
330
+
331
+ let Some ( entry) = MvccStream :: new ( reader) . next ( ) . transpose ( ) ? else {
332
+ return Ok ( None ) ;
333
+ } ;
334
+
335
+ // NOTE: We are past the searched key, so don't return anything
336
+ if & * entry. key . user_key > key {
337
+ return Ok ( None ) ;
338
+ }
339
+
340
+ Ok ( Some ( entry) )
344
341
}
345
342
346
343
// NOTE: Clippy false positive
@@ -380,6 +377,7 @@ impl Segment {
380
377
}
381
378
382
379
// TODO: move segment tests into module, then make pub(crate)
380
+
383
381
/// Creates an iterator over the `Segment`.
384
382
///
385
383
/// # Errors
@@ -389,14 +387,7 @@ impl Segment {
389
387
#[ allow( clippy:: iter_without_into_iter) ]
390
388
#[ doc( hidden) ]
391
389
pub fn iter ( & self ) -> Range {
392
- Range :: new (
393
- self . offsets . index_block_ptr ,
394
- self . descriptor_table . clone ( ) ,
395
- ( self . tree_id , self . metadata . id ) . into ( ) ,
396
- self . block_cache . clone ( ) ,
397
- self . block_index . clone ( ) ,
398
- ( std:: ops:: Bound :: Unbounded , std:: ops:: Bound :: Unbounded ) ,
399
- )
390
+ self . range ( ( std:: ops:: Bound :: Unbounded , std:: ops:: Bound :: Unbounded ) )
400
391
}
401
392
402
393
/// Creates a ranged iterator over the `Segment`.
0 commit comments