[
https://issues.apache.org/jira/browse/ARROW-2418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16430182#comment-16430182
]
ASF GitHub Bot commented on ARROW-2418:
---------------------------------------
xhochy closed pull request #1857: ARROW-2418: [Rust] BUG FIX: reserve memory
when building list
URL: https://github.com/apache/arrow/pull/1857
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/rust/src/list.rs b/rust/src/list.rs
index 461f8e645..a7b11a628 100644
--- a/rust/src/list.rs
+++ b/rust/src/list.rs
@@ -44,7 +44,9 @@ impl From<Vec<String>> for List<u8> {
let mut buf = BytesMut::with_capacity(v.len() * 32);
offsets.push(0_i32);
v.iter().for_each(|s| {
- buf.put(s.as_bytes());
+ let slice = s.as_bytes();
+ buf.reserve(slice.len());
+ buf.put(slice);
offsets.push(buf.len() as i32);
});
List {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Rust] List builder fails due to memory not being reserved correctly
> --------------------------------------------------------------------
>
> Key: ARROW-2418
> URL: https://issues.apache.org/jira/browse/ARROW-2418
> Project: Apache Arrow
> Issue Type: Bug
> Components: Rust
> Reporter: Andy Grove
> Assignee: Andy Grove
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.10.0
>
>
> I didn't realize that BytesMut.put() doesn't automatically grow the
> underlying buffer. Therefore the code fails if the data is large than the
> pre-allocated buffer.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)