Skip to main content

encode_segment

Function encode_segment 

Source
pub fn encode_segment<I>(
    rows: I,
    bloom_target_fp: f64,
    page_size_bytes: u32,
) -> Result<(Vec<u8>, SegmentMeta), SegmentError>
where I: ExactSizeIterator<Item = (u64, Vec<u8>)>,
Expand description

Build a complete segment as a single Vec<u8>. Caller writes the returned bytes to disk; subsequent reads happen via SegmentReader against either the full in-RAM slice (for the v5.0 standalone perf gates) or a seekable wrapper that pulls one page at a time (v5.1 catalog integration).

bloom_target_fp sizes the embedded bloom; the standard v5 default is 0.01 (1 % false-positive ceiling). Callers can trade per-segment bloom size for selectivity (smaller fp_rate → larger bloom).

rows must yield entries with ascending u64 keys; any descending or duplicate-out-of-order entry returns SegmentError::UnsortedKey.

page_size_bytes should be 4096 in v5.0 ship; the writer rejects values smaller than 256 (would force pathological page-count) and larger than 65536 (would defeat the page-granularity I/O assumption).