Asynchronous Queries
You can perform queries (reads or writes) asynchronously as follows:
C
C++
Python
R
Java
Go
1
// ... create read or write query
2
3
// Callback that simply prints the input string to stdout
4
void print_upon_completion(void* s) {
5
printf("%s\n", (char*)s);
6
}
7
// Instead of using tiledb_query_submit(), use tiledb_query_submit_async()
8
// and pass a callback function
9
char s[100] = "Callback: Query completed";
10
tiledb_query_submit_async(ctx, query, print_upon_completion, s);
Copied!
1
// ... create read or write query
2
3
// Instead of using query.submit(), use query.submit_async()
4
// and optionally pass a callback function
5
query.submit_async([]() { std::cout << "Callback: Query completed\n"; });
Copied!
1
# TODO: Asynchronous queries are not yet supported in the Python API
Copied!
1
# ... create read or write query
2
3
# Instead of using tiledb_query_submit(), use tiledb_query_submit_async()
4
# There is an alternate form with a callback function which is not yet supported
5
tiledb_query_submit_async(qry)
Copied!
1
private class ReadCallback implements Callback {
2
3
public ReadCallback() {}
4
5
public void call() {
6
System.out.println("Callback: Query completed");
7
}
8
}
9
10
// Submit query with callback
11
query.submitAsync(new ReadCallback());
Copied!
1
// ... create read or write query
2
3
// Instead of using Submit(), use SubmitAsync()
4
err = query.SubmitAsync()
5
6
fmt.Println("Read query in progress")
7
8
// Wait for status to return complete or to error
9
// Loop while status is inprogress
10
for status, err := query.Status(); status == tiledb.TILEDB_INPROGRESS &&
11
err == nil; status,
12
err = query.Status() {
13
// Do something while query is running
14
}
15
16
fmt.Println("Callback: Read query completed")
Copied!
Last modified 1yr ago
Copy link