You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "bkietz (via GitHub)" <gi...@apache.org> on 2023/07/06 14:07:52 UTC
[GitHub] [arrow] bkietz commented on a diff in pull request #36418: GH-36417: [C++] Add Buffer::data_as, Buffer::mutable_data_as
bkietz commented on code in PR #36418:
URL: https://github.com/apache/arrow/pull/36418#discussion_r1254497624
##########
cpp/src/arrow/buffer.h:
##########
@@ -137,6 +139,25 @@ class ARROW_EXPORT Buffer {
/// \return a new Buffer instance
static std::shared_ptr<Buffer> FromString(std::string data);
+ /// \brief Construct an immutable buffer that takes ownership of the contents
+ /// of an std::vector (without copying it).
+ ///
+ /// \param[in] data a string to own
+ /// \return a new Buffer instance
+ template <typename T>
+ static std::shared_ptr<Buffer> FromVector(std::vector<T> vec) {
Review Comment:
I'll rename and add a static assert for triviality of T.
I would prefer not to forbid copies just to prevent them from happening accidentally. This method would not be used in a performance critical context anyway. We build buffers with BufferBuilder in perf-critical contexts; I anticipate this mostly being useful in tests where requiring a call to something like `kj::cp` would get annoying.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org