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_resume(
&self,
dir: &GroupDirectory,
from_a: u32,
pb: Option<u32>,
pc: Option<u32>,
) -> BlockCursor<'a>
pub fn scan_resume( &self, dir: &GroupDirectory, from_a: u32, pb: Option<u32>, pc: Option<u32>, ) -> BlockCursor<'a>
Resume a leading-unbound scan at the first a-group whose leading id
is >= from_a, jumping there through the directory instead of re-walking
the groups already consumed. Yields exactly the tail of
scan(None, pb, pc) that begins at that group; from_a = 0 is the whole
block.
This is what lets a batched cursor stop in the middle of a block and
pick up where it left off without rescanning — the difference between an
O(n) resumable scan and an O(n²/batch) skip-and-take. Its bound-leading
twin is scan_from, which pins pa to one group;
here pa stays unbound and from_a is only a starting point, so the
cursor runs on through every later group.
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.