paleolimbot commented on PR #985:
URL: https://github.com/apache/arrow-adbc/pull/985#issuecomment-2097368791

   @krlmlr I updated this a bit with a new approach that floated in as I was 
working on some other things. The callback-based approach came from me working 
with Arrow C++, where we have a lot of helpers for this kind of thing. I think 
the new approach (based on `std::future`) is simpler and generalizes better; 
however I'm happy to revert to the previous approach if you think it will 
integrate better. I wish that `later` provided a cleaner way to poll something 
than to reschedule a task every xxx seconds...obviously polling is suboptimal 
but I think here we're stuck doing it one way or another.
   
   It would be nice to figure out how `read_adbc_async()` or 
`write_adbc_async()` or `execute_adbc_async()` might look...`read_adbc_async()` 
would be the most difficult because there are at 2-3 async calls that might 
have to get chained together (or we could wrap them all in a single async task 
that collects the entire array stream). I think there also needs to be some way 
to "lock" a connection to prevent other things from happening while stuff is 
happening on another thread (or maybe that's built in to the drivers?).
   
   The code I'm using to play with this is:
   
   ```r
   adbc_async_sleep(10000) |> 
     adbc_async_task_wait()
   ```
   
   ...to ensure that `adbc_async_task_wait()` can be interrupted and
   
   ```r
   library(adbcdrivermanager)
   
   flights <- nycflights13::flights
   
   con <- adbc_database_init(adbcpostgresql::adbcpostgresql(), 
                             uri = Sys.getenv("ADBC_POSTGRESQL_TEST_URI")) |> 
     adbc_connection_init()
   
   stmt <- adbc_statement_init(con, adbc.ingest.target_table = "flights")
   adbc_statement_bind_stream(stmt, flights)
   task <- adbc_statement_execute_query_async(stmt)
   # You should be able to request cancel using Control-C here
   adbc_async_task_wait(task)
   ```
   
   ...for a more real-world scenario.
   
   


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