CurtHagenlocher commented on issue #811:
URL: https://github.com/apache/arrow-adbc/issues/811#issuecomment-2087736516

   I've been starting to play around with this, and the management of the data 
structures is a bit annoying. It also isn't very consistent with other parts of 
the Arrow C API where the receiver of a call is free to move structures around 
in memory as long as it preserves the bits. Here's an alternative whose memory 
management is more like the synchronous API:
   
   `struct ArrowAsyncInfo {
       void* caller_data;
       void* private_data;
       void (*release)(struct ArrowAsyncInfo*);
   };
   
   AdbcStatusCode AdbcConnectionGetTableSchemaAsync(
       struct AdbcConnection* connection,
       const char* catalog,
       const char* db_schema,
       const char* table_name,
       struct ArrowAsyncInfo* asyncInfo,
       void (*complete)(struct ArrowAsyncInfo*, AdbcStatus, struct AdbcSchema*, 
struct AdbcError*);
   };`
   
   In this variation, the caller allocates (and is free to move) 
`ArrowAsyncInfo` and populates `caller_data`. The receiver fills the 
`private_data` and `release` fields and makes a copy for itself. On completion, 
the receiver calls the `complete` callback with its copy of `ArrowAsyncInfo` 
and its own buffers for the result (which can be `nullptr` on error) and the 
result status. It's the original caller's responsibility to clean these up at 
an appropriate time by invoking the corresponding `release`. The original 
caller then signals that it will no longer call AdbcCancel by calling `release` 
on `ArrowAsyncInfo`.
   
   The primary drawback of this variation is that it doesn't cleanly support 
synchronous completion of the call. On the other hand, there was nothing in the 
initial sketch which would have prevented the completion callback from 
happening before the original async call returned, and that fact is a bit more 
obvious with this approach.


-- 
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]

Reply via email to