houqp commented on a change in pull request #7324:
URL: https://github.com/apache/arrow/pull/7324#discussion_r437861027
##########
File path: rust/arrow/src/array/builder.rs
##########
@@ -1123,29 +1123,35 @@ fn append_binary_data(
}
}
- for array in data {
- // convert string to List<u8> to reuse list's cast
- let int_data = &array.buffers()[1];
- let int_data = Arc::new(ArrayData::new(
- DataType::UInt8,
- int_data.len(),
- None,
- None,
- 0,
- vec![int_data.clone()],
- vec![],
- )) as ArrayDataRef;
- let list_data = Arc::new(ArrayData::new(
- DataType::List(Box::new(DataType::UInt8)),
- array.len(),
- None,
- array.null_buffer().map(|buf| buf.clone()),
- array.offset(),
- vec![(&array.buffers()[0]).clone()],
- vec![int_data],
- ));
- builder.append_data(&[list_data])?;
- }
+ builder.append_data(
Review comment:
move append_data out of the for loop so memory allocation count for
buffers is constant.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]