CurtHagenlocher commented on issue #811:
URL: https://github.com/apache/arrow-adbc/issues/811#issuecomment-2059594637
Presumably we want more than ArrayStream to be async. In principle, any API
that might require a database round trip should support it though in practice
perhaps that might be unwieldy.
Of course, every language has different idioms and capabilities when it
comes to async and maybe it's not realistic to expose this in the C API and
expect to be able to interact with it from all languages. The simplest thing is
a callback which says "I'm done" and both C# and Rust can be made to work with
that. I have no idea about Go. Java might need to spawn a thread to make that
work (but with green threads on the horizon that could be okay).
The "straw person" would be something like -- and this is really rough --
```
struct ArrowAsyncInfo {
void* caller_data;
void* private_data; // belongs to the driver, nullptr if not currently
"active"
void (*complete)(struct ArrowAsyncInfo*, AdbcStatusCode);
};
AdbcStatusCode AdbcCancel(struct ArrowAsyncInfo *asyncInfo);
AdbcStatusCode ConnectionGetTableSchemaAsync(
struct AdbcConnection* connection,
const char* catalog,
const char* db_schema,
const char* table_name,
struct ArrowSchema* schema,
struct AdbcError* error,
struct ArrowAsyncInfo *asyncInfo);
```
The caller populates ArrowAsyncInfo with caller_data and completion handler
and initializes private_data to nullptr. It then calls
ConnectionGetTableSchemaAsync, which can return an error, success indicating
synchronous completion or success indicating initiation of an asynchronous
operation. In the latter case, it also populates the private_data field.
When the operation succeeds or fails, the driver cleans up private_data
before calling the completion function with the status of the operation.
The consumer may call AdbcCancel in order to terminate the operation. This
should either fail or return asynchronously, and cancellation isn't complete
until the completion function is called with a cancelled status. Note that an
operation may still succeed after it has been cancelled due to timing issues.
The driver may have to play games with sentinel values in the private_data
field and interlocked exchanges in order to make concurrency work out with
cancellation.
--
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]