alamb commented on code in PR #10176:
URL: https://github.com/apache/arrow-rs/pull/10176#discussion_r3453262638
##########
arrow-select/src/take.rs:
##########
@@ -256,11 +256,18 @@ fn take_impl<IndexType: ArrowPrimitiveType>(
*length as u32,
)?))
}
- DataType::Map(_, _) => {
+ DataType::Map(field, ordered) => {
let list_arr = ListArray::from(values.as_map().clone());
let list_data = take_list::<_, Int32Type>(&list_arr, indices)?;
- let builder =
list_data.into_data().into_builder().data_type(values.data_type().clone());
- Ok(Arc::new(MapArray::from(unsafe { builder.build_unchecked() })))
+ let (_, offsets, entries, nulls) = list_data.into_parts();
+ let entries = entries.as_struct().clone();
+ Ok(Arc::new(MapArray::try_new(
Review Comment:
I suggest we switch back to `MapArray::new_unchecked`
##########
arrow-select/src/take.rs:
##########
@@ -710,18 +717,15 @@ where
"New offsets was filled under/over the expected capacity"
);
- let child_data = array_data.freeze();
- let value_offsets = Buffer::from_vec(new_offsets);
-
- let list_data = ArrayDataBuilder::new(values.data_type().clone())
- .len(indices.len())
- .nulls(nulls)
- .offset(0)
- .add_child_data(child_data)
- .add_buffer(value_offsets);
+ let field = match values.data_type() {
+ DataType::List(field) | DataType::LargeList(field) => field.clone(),
+ d => unreachable!("take_list called with non-list data type {d}"),
+ };
+ // SAFETY: `new_offsets` is constructed to be monotonically increasing
above
+ let offsets = unsafe {
OffsetBuffer::new_unchecked(ScalarBuffer::from(new_offsets)) };
+ let child = make_array(array_data.freeze());
- let list_data = unsafe { list_data.build_unchecked() };
- Ok(GenericListArray::<OffsetType::Native>::from(list_data))
+ GenericListArray::<OffsetType::Native>::try_new(field, offsets, child,
nulls)
Review Comment:
yeah, as above I think we should use `new_unchecked`
--
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]