pub struct ValidityBitmap<'v> { /* private fields */ }Expand description
A wrapper around a DuckDB validity bitmap for reading or writing NULL flags.
Obtain a writable instance via ValidityBitmap::ensure_writable. For
read-only access, use ValidityBitmap::get_read_only.
§Safety invariants
The underlying duckdb_vector must remain valid for the lifetime 'v of
this wrapper. Do not call duckdb_destroy_data_chunk while a ValidityBitmap
that references the vector is live.
Implementations§
Source§impl ValidityBitmap<'_>
impl ValidityBitmap<'_>
Sourcepub unsafe fn ensure_writable(vector: duckdb_vector) -> Self
pub unsafe fn ensure_writable(vector: duckdb_vector) -> Self
Ensures the validity bitmap is writable and returns a ValidityBitmap.
This calls duckdb_vector_ensure_validity_writable before
duckdb_vector_get_validity, which is required before writing NULL flags.
§Pitfall L4
Calling duckdb_vector_get_validity without first calling
duckdb_vector_ensure_validity_writable returns NULL when the vector
has no mask yet, and NULLs written through that are silently dropped.
§Safety
vector must be a valid DuckDB vector handle obtained from a data chunk
within the current callback invocation. The vector must not be destroyed
while the returned ValidityBitmap is live. If vector lies inside the
child of a LIST or MAP vector — is that child, or a STRUCT field or
ARRAY element vector below it with no other LIST or MAP in between —
the bitmap must not be used after that LIST or MAP is grown with a
reserve, which reallocates the validity buffer of every such vector.
Sourcepub unsafe fn get_read_only(vector: duckdb_vector) -> Self
pub unsafe fn get_read_only(vector: duckdb_vector) -> Self
Gets the validity bitmap for read-only NULL checks.
§Safety
vector must be a valid DuckDB vector handle. The returned pointer may
be null if the vector has no validity bitmap (all rows are valid).
Sourcepub unsafe fn row_is_valid(&self, idx: idx_t) -> bool
pub unsafe fn row_is_valid(&self, idx: idx_t) -> bool
Returns true if the row at idx is valid (non-NULL).
If the validity bitmap pointer is null (all rows are valid), always returns
true.
§Safety
idx must be less than the number of rows in the vector.
Sourcepub unsafe fn set_row_invalid(&mut self, idx: idx_t)
pub unsafe fn set_row_invalid(&mut self, idx: idx_t)
Marks the row at idx as NULL (invalid).
This touches only this one mask. For a STRUCT or ARRAY vector, use
VectorWriter::set_null
instead, which also nulls the children as DuckDB expects.
§Safety
- This bitmap must have been created via
ensure_writable. idxmust be less than the number of rows in the vector.
Sourcepub unsafe fn set_row_valid(&mut self, idx: idx_t)
pub unsafe fn set_row_valid(&mut self, idx: idx_t)
Marks the row at idx as valid (non-NULL).
§Safety
- This bitmap must have been created via
ensure_writable. idxmust be less than the number of rows in the vector.