paleolimbot commented on code in PR #387:
URL: https://github.com/apache/arrow-nanoarrow/pull/387#discussion_r1492740468
##########
src/nanoarrow/nanoarrow.hpp:
##########
@@ -273,6 +280,49 @@ using UniqueArrayView = internal::Unique<struct
ArrowArrayView>;
/// @}
+/// \defgroup nanoarrow_hpp-buffer Buffer helpers
+///
+/// Helpers to wrap buffer-like C++ objects as ArrowBuffer objects that can
+/// be used to build ArrowArray objects.
+///
+/// @{
+
+/// \brief Initialize a buffer wrapping an arbitrary C++ object
+///
+/// Initializes a buffer with a release callback that deletes the moved obj
+/// when ArrowBufferReset is called. T must be movable.
+template <typename T>
+static inline void BufferInitWrapped(struct ArrowBuffer* buffer, T obj, const
void* ptr,
+ int64_t size_bytes) {
+ T* obj_moved = new T(std::move(obj));
+ buffer->data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(ptr));
+ buffer->size_bytes = size_bytes;
+ buffer->capacity_bytes = 0;
+ buffer->allocator =
+ ArrowBufferDeallocator(&internal::DeallocateWrappedBuffer<T>, obj_moved);
+}
Review Comment:
`std::unique_ptr<cudf::owned_buffer>` is what I had mind (but maybe this
more confusing than helpful!)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]