pub struct SegmentReader<'a> { /* private fields */ }Expand description
Read-side handle. Borrows the segment bytes (the catalog or
test owns the buffer), parses header + bloom + page index up
front, and exposes lookup(key) / scan_keys() over the rest.
For an in-RAM cold-tier segment that the catalog holds across
many lookups, prefer OwnedSegment — it owns its bytes and
reuses the same parsed metadata across calls without any
lifetime gymnastics.
Implementations§
Source§impl<'a> SegmentReader<'a>
impl<'a> SegmentReader<'a>
Sourcepub fn open(bytes: &'a [u8]) -> Result<Self, SegmentError>
pub fn open(bytes: &'a [u8]) -> Result<Self, SegmentError>
Parse a segment from a contiguous byte slice. Validates
magic, CRC32 footer, and structural lengths. v6.6.2: a
v2-magic envelope is rejected by the borrowed-slice reader
because decompression would need to allocate a fresh Vec —
callers with a v2 file must go through
OwnedSegment::from_bytes which can own the
decompressed bytes.
pub fn meta(&self) -> &SegmentMeta
Sourcepub fn codec_version(&self) -> u8
pub fn codec_version(&self) -> u8
v7.23/v7.27 — the codec version implied by this segment’s
inner magic (0 legacy / 46 / 47). Callers thread this into
decode_row_body_dense.
Sourcepub fn might_contain(&self, key: u64) -> bool
pub fn might_contain(&self, key: u64) -> bool
Bloom-only check — false means the key is definitely not
in this segment (no false negatives); true means it
might be (false-positive rate per the embedded bloom’s
target).