Skip to main content

Module struct_writer

Module struct_writer 

Source
Expand description

Batched, typed writer for STRUCT output vectors.

StructWriter pre-creates VectorWriters for every field at construction, then exposes typed write_* methods that take (row, field_idx, value). This eliminates the repetitive duckdb_struct_vector_get_child + manual VectorWriter creation that extension authors currently need for every field.

§Example

use quack_rs::vector::StructWriter;
use libduckdb_sys::duckdb_vector;

// Inside a scan callback, given a STRUCT output vector with 5 fields:
// let mut sw = unsafe { StructWriter::new(struct_vec, 5) };
// unsafe {
//     sw.write_bool(0, 0, result.success);
//     sw.write_varchar(0, 1, &result.data);
//     sw.write_i64(0, 2, result.lease);
//     sw.write_bool(0, 3, result.renewable);
//     sw.write_varchar(0, 4, &result.message);
// }

It fetches every field’s child vector once, up front, so a loop writing n rows of k fields makes k duckdb_struct_vector_get_child calls instead of one per write.

Structs§

StructWriter
A batched writer for STRUCT output vectors.