lidavidm commented on code in PR #44495:
URL: https://github.com/apache/arrow/pull/44495#discussion_r1809761188
##########
cpp/src/arrow/c/bridge.h:
##########
@@ -406,4 +407,75 @@ Result<std::shared_ptr<ChunkedArray>>
ImportDeviceChunkedArray(
/// @}
+/// \defgroup c-async-stream-interface Functions for working with the async C
data
+/// interface.
+///
+/// @{
+
+class AsyncErrorDetail : public StatusDetail {
+ public:
+ AsyncErrorDetail(int code, std::string message, std::string metadata)
+ : code_(code), message_(std::move(message)),
metadata_(std::move(metadata)) {}
+ const char* type_id() const override { return "AsyncErrorDetail"; }
+ std::string ToString() const override { return message_; }
+ int code() const { return code_; }
+ const std::string& ErrorMetadata() const { return metadata_; }
+
+ private:
+ int code_{0};
+ std::string message_;
+ std::string metadata_;
+};
+
+struct AsyncRecordBatchGenerator {
+ std::shared_ptr<Schema> schema;
+ DeviceAllocationType device_type;
+ AsyncGenerator<RecordBatchWithMetadata> generator;
+};
+
+namespace internal {
+class Executor;
+}
+
+/// \brief Create an AsyncRecordBatchReader and populate a corresponding
handler to pass
+/// to a producer
+///
+/// The ArrowAsyncDeviceStreamHandler struct is intended to have its callbacks
populated
+/// and then be passed to a producer to call the appropriate callbacks when
data is ready.
+/// This inverts the traditional flow of control, and so we construct a
corresponding
+/// AsyncRecordBatchReader to provide an interface for the consumer to
retrieve data as it
+/// is pushed to the handler.
+///
+/// \param[in,out] handler C struct to be populated
+/// \param[in] executor the executor to use for waiting and populating record
batches
+/// \param[in] queue_size initial number of record batches to request for
queueing
+/// \param[in] mapper mapping from device type and ID to memory manager
+/// \return Future that resolves to either an error or
AsyncRecordBatchGenerator once a
+/// schema is available or an error is received.
+ARROW_EXPORT
+Future<AsyncRecordBatchGenerator> CreateAsyncDeviceStreamHandler(
+ struct ArrowAsyncDeviceStreamHandler* handler, internal::Executor*
executor,
+ uint64_t queue_size = 5, const DeviceMemoryMapper mapper =
DefaultDeviceMemoryMapper);
Review Comment:
ah interesting...In that case maybe just make it `T` instead of `const T`
--
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]