Skip to main content

ValidityBitmap

Struct ValidityBitmap 

Source
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<'_>

Source

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.

Source

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).

Source

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.

Source

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.
  • idx must be less than the number of rows in the vector.
Source

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.
  • idx must be less than the number of rows in the vector.
Source

pub const fn as_raw(&self) -> *mut u64

Returns the raw validity bitmap pointer.

This is an escape hatch for code that needs direct bitmap access. Prefer the safe methods on this type when possible.

Trait Implementations§

Source§

impl<'v> Debug for ValidityBitmap<'v>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'v> !Send for ValidityBitmap<'v>

§

impl<'v> !Sync for ValidityBitmap<'v>

§

impl<'v> !UnwindSafe for ValidityBitmap<'v>

§

impl<'v> Freeze for ValidityBitmap<'v>

§

impl<'v> RefUnwindSafe for ValidityBitmap<'v>

§

impl<'v> Unpin for ValidityBitmap<'v>

§

impl<'v> UnsafeUnpin for ValidityBitmap<'v>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.