Skip to main content

Module vector

Module vector 

Source
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 — VectorWriter calls this automatically before any NULL-setting operation.
  • L5: Boolean reading — VectorReader always reads bytes as u8 != 0, never as bool, preventing undefined behaviour.
  • P7: duckdb_string_t format — string handles both the inline (≤12 bytes) and pointer (>12 bytes) cases.
  • Stale child pointers — ListBuilder re-fetches the child writer after every reserve, which reallocates the child vector. See list_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 LIST and MAP output vectors.
ops
Whole-vector operations (DuckDB 1.5.0+).
reader
Safe typed reading from DuckDB data vectors.
string
DuckDB VARCHAR and BLOB (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 and DuckDB’s vector storage.
validity
Validity bitmap helpers for DuckDB NULL tracking.
writer
Safe typed writing to DuckDB result 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).