paleolimbot opened a new pull request, #211:
URL: https://github.com/apache/arrow-nanoarrow/pull/211

   Total proof-of-concept of one way to go about async `stream$get_next()`, as 
discussed briefly with @krlmlr, @lidavidm, and @nbenn in connection with ADBC 
in R. When the stream is wrapping a database result set, the `get_next()` call 
can block for a considerable amount of time...this async version would support 
a world where it's easier to cancel running queries since we can loop + wait in 
R land (possibly calling the brand-new "cancel" function coming to ADBC 1.1).
   
   This PR currently will leak memory and doesn't communicate any error 
information beyond "result code".
   
   Reprex:
   
   ``` r
   library(nanoarrow)
   
   stream <- basic_array_stream(list(1:5))
   
   # ...more usefully, a promise or future whose value is set from the callback
   result <- NULL
   nanoarrow:::nanoarrow_array_stream_get_next_async(stream, function(code, 
array) {
     message("done!")
     result <<- array
   })
   
   Sys.sleep(0.5)
   nanoarrow:::run_callbacks()
   #> done!
   convert_array(result)
   #> [1] 1 2 3 4 5
   ```
   
   <sup>Created on 2023-06-07 with [reprex 
v2.0.2](https://reprex.tidyverse.org)</sup>


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