pub struct DictionaryBuilder { /* private fields */ }Expand description
Builds a Dictionary from observed (subject, predicate, object) terms.
Terms are deduped with HashSet during ingest (O(1) average insert, no tree
rebalancing) and sorted once in Self::build. This replaces a trio of
BTreeSet<String> whose per-insert O(log n) cost + a String allocation
for every observed term (most of them duplicates) dominated the build on
large graphs.
Implementations§
Source§impl DictionaryBuilder
impl DictionaryBuilder
pub fn new() -> DictionaryBuilder
Sourcepub fn observe(&mut self, subject: &str, predicate: &str, object: &str)
pub fn observe(&mut self, subject: &str, predicate: &str, object: &str)
Record one triple’s terms (IDs are assigned later, in Self::build).
We probe with the borrowed &str first and only allocate a String for
a genuinely new term — so a graph of N triples does far fewer than 3N
allocations (each subject/predicate recurs across many triples).
pub fn build(self) -> Dictionary
Trait Implementations§
Source§impl Default for DictionaryBuilder
impl Default for DictionaryBuilder
Source§fn default() -> DictionaryBuilder
fn default() -> DictionaryBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DictionaryBuilder
impl RefUnwindSafe for DictionaryBuilder
impl Send for DictionaryBuilder
impl Sync for DictionaryBuilder
impl Unpin for DictionaryBuilder
impl UnsafeUnpin for DictionaryBuilder
impl UnwindSafe for DictionaryBuilder
Blanket Implementations§
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
Mutably borrows from an owned value. Read more