MCPcopy Create free account
hub / github.com/apache/datafusion / async_table_provider_thread

Function async_table_provider_thread

datafusion/ffi/src/tests/async_provider.rs:57–91  ·  view source on GitHub ↗
(
    mut shutdown: mpsc::Receiver<bool>,
    mut batch_request: mpsc::Receiver<bool>,
    batch_sender: broadcast::Sender<Option<RecordBatch>>,
    tokio_rt: &mpsc::Sender<Handle>,
)

Source from the content-addressed store, hash-verified

55}
56
57fn async_table_provider_thread(
58 mut shutdown: mpsc::Receiver<bool>,
59 mut batch_request: mpsc::Receiver<bool>,
60 batch_sender: broadcast::Sender<Option<RecordBatch>>,
61 tokio_rt: &mpsc::Sender<Handle>,
62) {
63 let runtime = Arc::new(
64 tokio::runtime::Builder::new_current_thread()
65 .build()
66 .expect("Unable to create tokio runtime"),
67 );
68 let _runtime_guard = runtime.enter();
69 tokio_rt
70 .blocking_send(runtime.handle().clone())
71 .expect("Unable to send tokio runtime back to main thread");
72
73 runtime.block_on(async move {
74 let mut num_received = 0;
75 while let Some(true) = batch_request.recv().await {
76 let record_batch = match num_received {
77 0 => Some(create_record_batch(1, 5)),
78 1 => Some(create_record_batch(6, 1)),
79 2 => Some(create_record_batch(7, 5)),
80 _ => None,
81 };
82 num_received += 1;
83
84 if batch_sender.send(record_batch).is_err() {
85 break;
86 }
87 }
88 });
89
90 let _ = shutdown.blocking_recv();
91}
92
93pub fn start_async_provider() -> (AsyncTableProvider, Handle) {
94 let (batch_request_tx, batch_request_rx) = mpsc::channel(10);

Callers 1

start_async_providerFunction · 0.85

Calls 8

newFunction · 0.85
recvMethod · 0.80
is_errMethod · 0.80
create_record_batchFunction · 0.70
buildMethod · 0.45
cloneMethod · 0.45
handleMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…