Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::DuckDBAdbcConnectionWrapper Struct Reference
Collaboration diagram for duckdb::DuckDBAdbcConnectionWrapper:

Public Member Functions

void RegisterStream (duckdb_adbc::DuckDBAdbcStreamWrapper *stream)
 Register a stream wrapper so it can be materialized if another query runs on this connection.
 
void UnregisterStream (duckdb_adbc::DuckDBAdbcStreamWrapper *stream)
 Unregister a stream wrapper.
 
void MaterializeStreams ()
 Materialize all active streams, fetching remaining data into memory.
 
void DetachAndClearStreams ()
 Detach all streams from this connection and clear the list (called on connection release).
 

Public Attributes

duckdb_connection connection
 
unordered_map< string, string > options
 

Private Attributes

mutex stream_mutex
 
vector< duckdb_adbc::DuckDBAdbcStreamWrapper * > active_streams
 

Member Function Documentation

◆ RegisterStream()

void duckdb::DuckDBAdbcConnectionWrapper::RegisterStream ( duckdb_adbc::DuckDBAdbcStreamWrapper stream)

Register a stream wrapper so it can be materialized if another query runs on this connection.

29977 {
29978 const duckdb::lock_guard<duckdb::mutex> guard(stream_mutex);
29979 active_streams.push_back(stream);
29980}
Definition duckdb.hpp:960

◆ UnregisterStream()

void duckdb::DuckDBAdbcConnectionWrapper::UnregisterStream ( duckdb_adbc::DuckDBAdbcStreamWrapper stream)

Unregister a stream wrapper.

29982 {
29983 const duckdb::lock_guard<duckdb::mutex> guard(stream_mutex);
29984 auto it = std::find(active_streams.begin(), active_streams.end(), stream);
29985 if (it != active_streams.end()) {
29986 active_streams.erase(it);
29987 }
29988}

◆ MaterializeStreams()

void duckdb::DuckDBAdbcConnectionWrapper::MaterializeStreams ( )

Materialize all active streams, fetching remaining data into memory.

29990 {
29991 const duckdb::lock_guard<duckdb::mutex> guard(stream_mutex);
29992 for (auto *result_wrapper : active_streams) {
29993 if (!result_wrapper || result_wrapper->materialized) {
29994 continue;
29995 }
29996
29997 // Collect remaining batches from the streaming result
29999 auto arrow_options = duckdb_result_get_arrow_options(&result_wrapper->result);
30000 while (true) {
30001 ArrowArray array;
30002 std::memset(&array, 0, sizeof(ArrowArray));
30003
30004 auto duckdb_chunk = duckdb_fetch_chunk(result_wrapper->result);
30005 if (!duckdb_chunk) {
30006 break;
30007 }
30008 auto conversion_err = duckdb_data_chunk_to_arrow(arrow_options, duckdb_chunk, &array);
30009 duckdb_destroy_data_chunk(&duckdb_chunk);
30010
30011 if (conversion_err) {
30012 duckdb_destroy_error_data(&conversion_err);
30013 if (array.release) {
30014 array.release(&array);
30015 }
30016 break;
30017 }
30018 batches.push_back(array);
30019 }
30020 duckdb_destroy_arrow_options(&arrow_options);
30021
30022 // Store materialized data
30023 auto mat = static_cast<duckdb_adbc::MaterializedData *>(malloc(sizeof(duckdb_adbc::MaterializedData)));
30024 if (!mat) {
30025 // Allocation failed — release fetched batches and skip materialization
30026 for (auto &batch : batches) {
30027 if (batch.release) {
30028 batch.release(&batch);
30029 }
30030 }
30031 continue;
30032 }
30033 mat->current = 0;
30034 mat->count = static_cast<idx_t>(batches.size());
30035 if (!batches.empty()) {
30036 mat->batches = static_cast<ArrowArray *>(malloc(sizeof(ArrowArray) * batches.size()));
30037 if (!mat->batches) {
30038 // Allocation failed — release fetched batches and skip materialization
30039 for (auto &batch : batches) {
30040 if (batch.release) {
30041 batch.release(&batch);
30042 }
30043 }
30044 free(mat);
30045 continue;
30046 }
30047 for (idx_t i = 0; i < batches.size(); i++) {
30048 mat->batches[i] = batches[i];
30049 }
30050 } else {
30051 mat->batches = nullptr;
30052 }
30053 result_wrapper->materialized = mat;
30054 }
30055}
Definition duckdb.hpp:11287
void(* release)(struct ArrowArray *)
Release callback.
Definition duckdb.hpp:11299
Definition duckdb.cpp:27712

◆ DetachAndClearStreams()

void duckdb::DuckDBAdbcConnectionWrapper::DetachAndClearStreams ( )

Detach all streams from this connection and clear the list (called on connection release).

30057 {
30058 const duckdb::lock_guard<duckdb::mutex> guard(stream_mutex);
30059 for (auto *stream_wrapper : active_streams) {
30060 if (stream_wrapper) {
30061 stream_wrapper->conn_wrapper = nullptr;
30062 }
30063 }
30064 active_streams.clear();
30065}

The documentation for this struct was generated from the following file: