pub struct Q42LexMmap<'a> { /* private fields */ }Expand description
Zero-allocation view over a memory-mapped .q42.lex slice (sorted hash index).
Implementations§
Source§impl<'a> Q42LexMmap<'a>
impl<'a> Q42LexMmap<'a>
Sourcepub fn from_bytes(data: &'a [u8]) -> Result<Self, LexError>
pub fn from_bytes(data: &'a [u8]) -> Result<Self, LexError>
Parse a Q42LEX byte slice (typically from mmap).
pub fn entry_count(&self) -> usize
Sourcepub fn hash_at(&self, i: usize) -> Option<u64>
pub fn hash_at(&self, i: usize) -> Option<u64>
Hash at sorted ordinal i, independent of whether the lexicon is the
legacy flat layout or the paged v2 layout. Cold loaders use this rather
than reaching into an on-disk index with v1 assumptions.
Sourcepub fn lookup_hash(&self, hash: u64) -> Option<&'a str>
pub fn lookup_hash(&self, hash: u64) -> Option<&'a str>
Binary search for hash in the sorted index; returns the UTF-8 lexeme slice.
Sourcepub fn string_at(&self, i: usize) -> Option<&'a str>
pub fn string_at(&self, i: usize) -> Option<&'a str>
The lexeme string of the i-th index entry (0..entry_count), if it is a UTF-8 string entry
(not an embedded-triple / Webizen entry). Enables iterating ALL lexicon strings without knowing
their hashes — e.g. to assemble a calibration corpus from a WordNet q42’s gloss text.
Sourcepub fn lookup_embedded_triple(&self, hash: u64) -> Option<[u64; 3]>
pub fn lookup_embedded_triple(&self, hash: u64) -> Option<[u64; 3]>
Binary search for hash in the sorted index; returns the embedded triple [subject, predicate, object].
Used by SPARQL-Star Virtual ID resolution: a Virtual ID is the FNV-1a hash of an embedded
triple, stored in the lexicon with tag LEX_TAG_EMBEDDED instead of LEX_TAG_STRING.
Sourcepub fn lookup_webizen_identity(&self, hash: u64) -> Option<&'a str>
pub fn lookup_webizen_identity(&self, hash: u64) -> Option<&'a str>
Binary search for hash; returns the authoritative Webizen identity string.
Trait Implementations§
Source§impl<'a> Clone for Q42LexMmap<'a>
impl<'a> Clone for Q42LexMmap<'a>
Source§fn clone(&self) -> Q42LexMmap<'a>
fn clone(&self) -> Q42LexMmap<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for Q42LexMmap<'a>
impl<'a> Debug for Q42LexMmap<'a>
impl<'a> Copy for Q42LexMmap<'a>
Auto Trait Implementations§
impl<'a> Freeze for Q42LexMmap<'a>
impl<'a> RefUnwindSafe for Q42LexMmap<'a>
impl<'a> Send for Q42LexMmap<'a>
impl<'a> Sync for Q42LexMmap<'a>
impl<'a> Unpin for Q42LexMmap<'a>
impl<'a> UnsafeUnpin for Q42LexMmap<'a>
impl<'a> UnwindSafe for Q42LexMmap<'a>
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more