Skip to main content

build_offset_index

Function build_offset_index 

Source
pub fn build_offset_index<O, T>(
    buckets: Vec<Vec<T>>,
) -> Result<(Vec<O>, Vec<T>), OffsetOverflow>
where O: LayoutIndex,
Expand description

Flattens per-bucket payloads into a (offsets, items) pair.

The returned offsets vector has length buckets.len() + 1. offsets[0] is zero, offsets[i + 1] - offsets[i] equals the i-th bucket’s length, and offsets[buckets.len()] equals items.len(). Items appear in input order within each bucket and buckets are concatenated in input order.

§Errors

Returns OffsetOverflow::IndexOverflow when any cumulative offset does not fit in the target index width.

§Performance

This function is O(n) where n is the total item count across all buckets. Allocation matches a single-pass extend-and-grow; no second pass is performed.