pub struct OwnedVector { /* private fields */ }Expand description
A flat duckdb_vector this crate allocated, destroyed on drop.
DuckDB normally hands an extension the vectors it should read or write.
This is for the cases where an extension needs one of its own: a
destination for copy_selected, a staging buffer, or a vector to hand to
Appender::append_chunk.
Requires duckdb-1-5: duckdb_create_vector sits in the unstable region of
the C API struct.
Implementations§
Source§impl OwnedVector
impl OwnedVector
Sourcepub fn new(
logical_type: &LogicalType,
capacity: usize,
) -> Result<Self, ExtensionError>
pub fn new( logical_type: &LogicalType, capacity: usize, ) -> Result<Self, ExtensionError>
Allocates a flat vector of logical_type with room for capacity rows.
§Errors
Returns an error, before anything is allocated, if capacity — or
capacity times the sizes of the ARRAY types nested in
logical_type — exceeds MAX_CAPACITY. Also returns an error if
DuckDB refuses to allocate the vector: an INVALID or ANY type, or
an allocation that fails.
The capacity check is not optional hygiene. DuckDB sizes the buffer
as capacity * element_size with an unchecked multiply
(VectorBuffer::CreateStandardVector, vector_buffer.cpp), and an
ARRAY child as capacity * array_size, also unchecked. A capacity
that wraps gets a small buffer and a success return, and writes inside
the capacity this function reported would then overflow the heap.