Skip to content

Commit 7758889

Browse files
committed
optimize
1 parent b7b3f18 commit 7758889

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arrow-select/src/coalesce.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@ impl BatchCoalescer {
315315
let to_copy = remaining.min(space_in_batch);
316316

317317
// Find how many filter positions we need to cover `to_copy` set bits
318-
let chunk_len = find_nth_set_bit_position(filter, filter_pos, to_copy) - filter_pos;
318+
// Skip the expensive search if all remaining rows fit in the current batch
319+
let chunk_len = if remaining <= space_in_batch {
320+
filter.len() - filter_pos
321+
} else {
322+
find_nth_set_bit_position(filter, filter_pos, to_copy) - filter_pos
323+
};
319324

320325
let chunk_filter = filter.slice(filter_pos, chunk_len);
321326
let mut filter_builder = FilterBuilder::new(&chunk_filter);

0 commit comments

Comments
 (0)