[ 
https://issues.apache.org/jira/browse/ARROW-8367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Antoine Pitrou resolved ARROW-8367.
-----------------------------------
    Resolution: Fixed

Issue resolved by pull request 6869
[https://github.com/apache/arrow/pull/6869]

> [C++] Deprecate Buffer::FromString(..., pool) 
> ----------------------------------------------
>
>                 Key: ARROW-8367
>                 URL: https://issues.apache.org/jira/browse/ARROW-8367
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++
>    Affects Versions: 0.16.0
>            Reporter: Ben Kietzman
>            Assignee: Antoine Pitrou
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 0.17.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> From [https://github.com/apache/arrow/pull/6863#discussion_r404913683]
> There are currently two overloads of {{Buffer::FromString}}, one which takes 
> an rvalue reference to string and another which takes a const reference and a 
> MemoryPool. In the former case the string is simply moved into a Buffer 
> subclass while in the latter the MemoryPool is used to allocate space into 
> which the string's contents are copied, which necessitates bubbling the 
> potential allocation failure. This seems gratuitous given we don't use 
> {{std::string}} to store large quantities so it should be fine to provide only
> {code:java}
>   static std::unique_ptr<Buffer> FromString(std::string data); 
> {code}
> and rely on {{std::string}}'s copy constructor when the argument is not an 
> rvalue.
> In the case of a {{std::string}} which may/does contain large data and must 
> be copied, tracking the copied memory with a MemoryPool does not require a 
> great deal of boilerplate:
> {code:java}
> ARROW_ASSIGN_OR_RAISE(auto buffer,
>                       Buffer(large).CopySlice(0, large.size(), pool));
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to