Expand description
Safe helpers for reading from and writing to DuckDB data vectors.
DuckDB represents columnar data as “vectors” — arrays of typed values
with an associated validity bitmap for NULL tracking. This module provides
safe wrappers that eliminate the raw pointer arithmetic and undocumented
struct layouts that trip up extension authors.
§Pitfalls solved by this module
- L4:
ensure_validity_writable—VectorWritercalls this automatically before any NULL-setting operation. - L5: Boolean reading —
VectorReaderalways reads bytes asu8 != 0, never asbool, preventing undefined behaviour. - P7:
duckdb_string_tformat —stringhandles both the inline (≤12 bytes) and pointer (>12 bytes) cases. - Stale child pointers —
ListBuilderre-fetches the child writer after everyreserve, which reallocates the child vector. Seelist_builder.
Re-exports§
pub use list_builder::max_child_capacity;pub use list_builder::ListBuilder;pub use list_builder::MAX_LIST_CHILD_CAPACITY;pub use ops::OwnedVector;pub use reader::VectorReader;pub use string::read_duck_blob;pub use string::read_duck_string;pub use string::DuckStringView;pub use struct_reader::StructReader;pub use struct_writer::StructWriter;pub use uuid::uuid_from_storage;pub use uuid::uuid_to_storage;pub use validity::ValidityBitmap;pub use writer::VectorWriter;
Modules§
- complex
- Complex type vector operations: STRUCT fields, LIST elements, MAP entries.
- list_
builder - Safe construction of
LISTandMAPoutput vectors. - ops
- Whole-vector operations (
DuckDB1.5.0+). - reader
- Safe typed reading from
DuckDBdata vectors. - string
DuckDBVARCHARandBLOB(duckdb_string_t) reading utilities.- struct_
reader - Batched, typed reader for STRUCT input vectors.
- struct_
writer - Batched, typed writer for STRUCT output vectors.
- uuid
- Converting between a
UUID’s textual bits andDuckDB’s vector storage. - validity
- Validity bitmap helpers for
DuckDBNULL tracking. - writer
- Safe typed writing to
DuckDBresult vectors.
Functions§
- vector_
get_ ⚠column_ type - Returns the logical type of a vector.
- vector_
size - Returns the default vector size used by
DuckDB(typically 2048).