refine prune_blocks_sync
@@ -263,13 +263,11 @@ impl BlockPruner {
segment_idx: SegmentIndex,
segment_info: &SegmentInfo,
) -> Vec<(SegmentIndex, BlockMeta)> {
- segment_info
- .blocks
- .iter()
- .filter_map(|block_meta| {
+ let mut result = Vec::with_capacity(segment_info.blocks.len());
+ for block_meta in &segment_info.blocks {
// check limit speculatively
if pruning_ctx.limiter.exceeded() {
- return None;
+ break;
}
let row_count = block_meta.row_count;
if pruning_ctx
@@ -277,12 +275,10 @@ impl BlockPruner {
.should_keep(&block_meta.col_stats, row_count)
&& pruning_ctx.limiter.within_limit(row_count)
{
- Some((segment_idx, block_meta.clone()))
- } else {
- None
+ result.push((segment_idx, block_meta.clone()))
}
- })
- .collect()
+ }
+ result
}
#[inline]
