@@ -657,26 +657,26 @@ impl Engine {
657
657
max_count : u64 ,
658
658
) -> Result < u64 > {
659
659
let chunks = self . meta_store . query_chunks ( begin, end, max_count) ?;
660
- let chunks_len = chunks. len ( ) ;
660
+ let mut offset = 0 ;
661
+
661
662
const BATCH_SIZE : Size = Size :: mebibyte ( 1 ) ;
662
663
let mut write_batch = RocksDB :: new_write_batch ( ) ;
663
- let mut persist_end = 0 ;
664
664
for ( index, ( chunk_id, meta) ) in chunks. iter ( ) . enumerate ( ) {
665
665
if write_batch. size_in_bytes ( ) >= BATCH_SIZE . 0 as _ {
666
666
self . meta_store . write ( write_batch, true ) ?;
667
- for i in persist_end..index + 1 {
668
- self . meta_cache . remove ( & chunks[ i] . 0 ) ;
669
- }
670
- persist_end = index + 1 ;
671
667
write_batch = RocksDB :: new_write_batch ( ) ;
668
+ for ( chunk_id, _) in & chunks[ offset..index] {
669
+ self . meta_cache . remove ( chunk_id) ;
670
+ }
671
+ offset = index;
672
672
}
673
673
self . meta_store
674
674
. remove_mut ( & chunk_id, & meta, & mut write_batch) ?;
675
675
}
676
676
if !write_batch. is_empty ( ) {
677
677
self . meta_store . write ( write_batch, true ) ?;
678
- for i in persist_end..chunks_len {
679
- self . meta_cache . remove ( & chunks [ i ] . 0 ) ;
678
+ for ( chunk_id , _ ) in & chunks [ offset.. ] {
679
+ self . meta_cache . remove ( chunk_id ) ;
680
680
}
681
681
}
682
682
Ok ( chunks. len ( ) as _ )
0 commit comments