Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
0.16.0
Description
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
static std::unique_ptr<Buffer> FromString(std::string data);
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:
ARROW_ASSIGN_OR_RAISE(auto buffer, Buffer(large).CopySlice(0, large.size(), pool));
Attachments
Issue Links
- links to