Skip to content

Commit 1272caf

Browse files
committed
Avoid copies in take_state
1 parent f0554ce commit 1272caf

File tree

1 file changed

+2
-6
lines changed
  • datafusion/functions-aggregate/src/first_last

1 file changed

+2
-6
lines changed

datafusion/functions-aggregate/src/first_last/state.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,9 @@ pub(crate) fn take_need(
300300
EmitTo::First(n) => {
301301
// split off the first N values in seen_values
302302
//
303-
// TODO make this more efficient rather than two
304-
// copies and bitwise manipulation
305-
let first_n: BooleanBuffer = bool_buf.iter().take(n).collect();
303+
let first_n: BooleanBuffer = bool_buf.slice(0, n);
306304
// reset the existing buffer
307-
for b in bool_buf.iter().skip(n) {
308-
bool_buf_builder.append(b);
309-
}
305+
bool_buf_builder.append_buffer(&bool_buf.slice(n, bool_buf.len() - n));
310306
first_n
311307
}
312308
}

0 commit comments

Comments
 (0)