pub struct TripleBlock<'a> { /* private fields */ }Expand description
A parsed triple block.
Implementations§
Source§impl<'a> TripleBlock<'a>
impl<'a> TripleBlock<'a>
pub fn parse(bytes: &'a [u8]) -> Result<TripleBlock<'a>, TripleError>
pub fn zone(&self) -> &ZoneMap
Sourcepub fn triples(&self) -> Vec<(u32, u32, u32)>
pub fn triples(&self) -> Vec<(u32, u32, u32)>
Decode all triples in ascending order. The bytes may be corrupt (a block from an untrusted file), so decoding is bounds-safe and stops gracefully at the first malformed varint rather than panicking — returning whatever prefix decoded cleanly.
Sourcepub fn group_directory(&self) -> GroupDirectory
pub fn group_directory(&self) -> GroupDirectory
Build the byte-offset directory of this block’s a-groups (one header
walk), enabling binary-search probes via scan_from.
On corrupt bytes the walk stops early — the directory is a prefix, and
the bounds-checked cursor degrades gracefully like every other reader.
Sourcepub fn scan_from(
&self,
dir: &GroupDirectory,
pa: u32,
pb: Option<u32>,
pc: Option<u32>,
) -> BlockCursor<'a>
pub fn scan_from( &self, dir: &GroupDirectory, pa: u32, pb: Option<u32>, pc: Option<u32>, ) -> BlockCursor<'a>
Probe the block for a bound leading component pa, jumping straight
to its a-group through the directory (binary search) instead of walking
every preceding group header. Yields exactly what
scan(Some(pa), pb, pc) would.
Sourcepub fn scan(
&self,
pa: Option<u32>,
pb: Option<u32>,
pc: Option<u32>,
) -> BlockCursor<'a>
pub fn scan( &self, pa: Option<u32>, pb: Option<u32>, pc: Option<u32>, ) -> BlockCursor<'a>
Stream the triples matching a (permuted) pattern, without decoding the
whole block. pa/pb/pc are the bound components in this block’s stored
order (None = wildcard). The cursor walks the grouped body and:
- range-stops once the leading component
aexceeds a boundpa— the a-groups are stored ascending, so nothing later can match (the early-out that makes a leading-bound lookupO(matches + preceding groups)instead ofO(whole block)); - group-skips a/b groups that can’t match (decoding their headers to advance, but never building or emitting their triples);
- equality-filters
pb/pcwithout ever early-breaking inside a c-list, so on a valid block the yielded set equals whattripleswould yield filtered — even on corrupt bytes it only ever yields fewer, never panics (every read is bounds-checked).
Yields triples in this block’s stored (a, b, c) order; callers map back
to canonical (s, p, o) themselves.