tustvold commented on code in PR #6622:
URL: https://github.com/apache/arrow-rs/pull/6622#discussion_r1815607032
##########
arrow-select/src/take.rs:
##########
@@ -459,11 +461,10 @@ fn take_bytes<T: ByteArrayType, IndexType:
ArrowPrimitiveType>(
) -> Result<GenericByteArray<T>, ArrowError> {
let data_len = indices.len();
- let bytes_offset = (data_len + 1) * std::mem::size_of::<T::Offset>();
- let mut offsets = MutableBuffer::new(bytes_offset);
+ let mut offsets = Vec::with_capacity(data_len + 1);
offsets.push(T::Offset::default());
- let mut values = MutableBuffer::new(0);
+ let mut values = Vec::new();
Review Comment:
This change seems unrelated to the benchmarks?
##########
arrow-select/src/take.rs:
##########
@@ -424,24 +424,26 @@ fn take_bits<I: ArrowPrimitiveType>(
indices: &PrimitiveArray<I>,
) -> BooleanBuffer {
let len = indices.len();
- let mut output_buffer = MutableBuffer::new_null(len);
- let output_slice = output_buffer.as_slice_mut();
match indices.nulls().filter(|n| n.null_count() > 0) {
- Some(nulls) => nulls.valid_indices().for_each(|idx| {
- if values.value(indices.value(idx).as_usize()) {
- bit_util::set_bit(output_slice, idx);
- }
- }),
- None => indices.values().iter().enumerate().for_each(|(i, index)| {
- if values.value(index.as_usize()) {
- bit_util::set_bit(output_slice, i);
- }
- }),
+ Some(nulls) => {
+ let mut output_buffer = MutableBuffer::new_null(len);
+ let output_slice = output_buffer.as_slice_mut();
+ nulls.valid_indices().for_each(|idx| {
+ if values.value(indices.value(idx).as_usize()) {
+ bit_util::set_bit(output_slice, idx);
+ }
+ });
+ BooleanBuffer::new(output_buffer.into(), 0, len)
+ }
+ None => {
+ BooleanBuffer::collect_bool(len, |idx: usize| {
Review Comment:
This appears to be the major change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]