-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARROW-1600: [C++] Add Buffer constructor that wraps std::string #1147
Conversation
Change-Id: Ic41686a276f35c61f4fa0aca9f79f2b4c3e91482
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Minor comments.
cpp/src/arrow/buffer-test.cc
Outdated
@@ -46,6 +46,14 @@ TEST_F(TestBuffer, IsMutableFlag) { | |||
ASSERT_TRUE(pbuf.is_mutable()); | |||
} | |||
|
|||
TEST_F(TestBuffer, FromStdString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be TEST_F
or can it just be TEST
? It doesn't appear to be using any of the members of TestBuffer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the fixture and made everything TEST
since none of them were using it
/// \param[in] data a memory buffer | ||
/// \param[in] size buffer size | ||
/// | ||
/// \note The passed memory must be kept alive through some other means |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would ASAN be able to detect this kind of lifetime error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, and you would segfault if you tried accessing the memory that had already been freed
Change-Id: If2e103879b5627c12b717eab459a248b0b89cf20
Many other libraries interchange binary data with `std::string`. This makes it easy to wrap such data in an `arrow::Buffer`. It may be worth adding a function that creates a buffer from a string, but owns its memory. I also deprecated `arrow::GetBufferFromString`, which shouldn't have been public in the first place, since the new ctor is more general Author: Wes McKinney <wes.mckinney@twosigma.com> Closes apache#1147 from wesm/ARROW-1600 and squashes the following commits: f60f502 [Wes McKinney] Remove TestBuffer fixture 644bf2b [Wes McKinney] Add Buffer ctor that wraps std::string
Many other libraries interchange binary data with
std::string
. This makes it easy to wrap such data in anarrow::Buffer
.It may be worth adding a function that creates a buffer from a string, but owns its memory.
I also deprecated
arrow::GetBufferFromString
, which shouldn't have been public in the first place, since the new ctor is more general