Skip to main content

MAX_CAPACITY

Constant MAX_CAPACITY 

Source
pub const MAX_CAPACITY: usize = _; // 137_438_953_472usize
Expand description

The most elements OwnedVector::new will ask DuckDB to put in one vector.

This is DConstants::MAX_VECTOR_SIZE (2^37), the same ceiling DuckDB enforces when a list child vector grows (VectorListBuffer::Reserve).

It applies to the vector itself and to every child vector it creates. An ARRAY(T, n) child holds capacity * n elements, so an array type lowers the usable row capacity accordingly. Every physical element is at most 16 bytes, so a vector within this bound needs at most 2 TiB and its size can never wrap a 64-bit multiply.

On a 32-bit target (wasm32) the allocation is the tighter bound: DuckDB narrows a buffer’s 64-bit size to size_t when it allocates, so a vector of 2^32 bytes or more would get a wrapped, undersized buffer. There the bound is the most 16-byte elements whose bytes fit a usize, 2^28 - 1.