pub unsafe fn slice(vector: duckdb_vector, sel: &SelectionVector, len: usize)Expand description
Reorders or filters vector in place through sel, without copying its
payload.
§This makes the vector non-flat
duckdb.h: “Turns the vector into a dictionary vector.” Row i of the
result is element sel[i] of the original payload, so
duckdb_vector_get_data — and therefore every
VectorReader in this crate — no longer
indexes it correctly. Nothing detects this at run time; the reads are simply
wrong.
Use it when the vector’s next stop is DuckDB itself, which understands
dictionary vectors. When you need to read the result, use
copy_selected into a flat destination instead.
§Safety
vectormust be a valid vector this extension owns or was handed to write.lenmust not exceed the vector’s length, and every index insel[..len]must be a valid row ofvector.- No
VectorReaderorVectorWriterovervectormay be used afterwards: both cache the pre-slice data pointer and both assume flat indexing. selmust not be modified whilevectoris in use.DuckDBcopies aSelectionVectorby sharing its buffer (selection_vector.hpp), so the sliced vector reads throughsel’s indices, not a copy of them: a later write throughSelectionVector::as_mut_slicesilently changes which rowsvectorholds. Droppingselis fine — the shared buffer is reference-counted.