Skip to main content

MAX_LEN

Constant MAX_LEN 

Source
pub const MAX_LEN: usize = _; // 4_294_967_296usize
Expand description

The largest length SelectionVector::new accepts.

This is 2^32 — the number of distinct source rows a [sel_t] (u32) index can name — on 64-bit targets, and the largest sel_t slice that fits in isize::MAX bytes on 32-bit ones.

DuckDB does no checking of its own here: duckdb_create_selection_vector computes size * sizeof(sel_t) without an overflow check (so a large enough size wraps to a tiny allocation while the caller believes it owns size indices), and at Allocator::MAXIMUM_ALLOC_SIZE (2^48 bytes) or above it throws a C++ exception, which aborts an extension. Capping the length at the range of sel_t keeps the byte count at most 2^34, far from both. Real selection vectors are sized in vector rows — STANDARD_VECTOR_SIZE (2048) in ordinary execution — so the cap rejects only lengths no operation could use.