You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Panchen Xue (JIRA)" <ji...@apache.org> on 2018/01/23 23:32:00 UTC
[jira] [Comment Edited] (ARROW-1623) [C++] Add convenience method
to construct Buffer from a string that owns its memory
[ https://issues.apache.org/jira/browse/ARROW-1623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16336545#comment-16336545 ]
Panchen Xue edited comment on ARROW-1623 at 1/23/18 11:31 PM:
--------------------------------------------------------------
My understanding is:
Status Buffer::FromString(const std::string& data, MemoryPool* pool,
std::shared_ptr<Buffer>* out) const {
auto new_buffer = std::make_shared<PoolBuffer>(pool);
auto size = static_cast<int64_t>(data.size());
auto str = reinterpret_cast<const uint8_t*>(data.c_str());
RETURN_NOT_OK(new_buffer->Resize(size));
std::memcpy(new_buffer->mutable_data(), str, size);
*out = new_buffer;
return Status::OK();
}
If this is correct, shall we make this a static method?
was (Author: 1xuepanchen1):
My understanding is:
Status Buffer::FromString(const std::string& data, MemoryPool* pool,
std::shared_ptr<Buffer>* out) const {
auto new_buffer = std::make_shared<PoolBuffer>(pool);
auto size = static_cast<int64_t>(data.size());
auto str = reinterpret_cast<const uint8_t*>(data.c_str());
RETURN_NOT_OK(new_buffer->Resize(size));
std::memcpy(new_buffer->mutable_data(), str, size);
*out = new_buffer;
return Status::OK();
}
If this is correct, shall we make this a static method?
> [C++] Add convenience method to construct Buffer from a string that owns its memory
> -----------------------------------------------------------------------------------
>
> Key: ARROW-1623
> URL: https://issues.apache.org/jira/browse/ARROW-1623
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C++
> Reporter: Wes McKinney
> Assignee: Panchen Xue
> Priority: Major
> Fix For: 0.9.0
>
>
> The memory would need to be allocated from a memory pool / buffer allocator
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)