pub struct NodeTable { /* private fields */ }Expand description
NodeTable provides bidirectional mapping between Terms and NodeIds
Uses two B+Trees:
- term_to_id: Term → NodeId (for encoding)
- id_to_term: NodeId → Term (for decoding)
§Prefix Compression
For IRI terms, the NodeTable automatically applies prefix compression to reduce storage overhead. Common IRI prefixes (namespaces) are stored once and referenced by ID, significantly reducing memory usage for datasets with many IRIs sharing the same namespace.
Implementations§
Source§impl NodeTable
impl NodeTable
Sourcepub fn new(buffer_pool: Arc<BufferPool>) -> Self
pub fn new(buffer_pool: Arc<BufferPool>) -> Self
Create a new NodeTable with prefix compression enabled
Sourcepub fn with_compression(
buffer_pool: Arc<BufferPool>,
compression_enabled: bool,
) -> Self
pub fn with_compression( buffer_pool: Arc<BufferPool>, compression_enabled: bool, ) -> Self
Create a new NodeTable with configurable compression
Sourcepub fn from_roots(
buffer_pool: Arc<BufferPool>,
term_to_id_root: Option<PageId>,
id_to_term_root: Option<PageId>,
next_id: NodeId,
) -> Self
pub fn from_roots( buffer_pool: Arc<BufferPool>, term_to_id_root: Option<PageId>, id_to_term_root: Option<PageId>, next_id: NodeId, ) -> Self
Reconstruct a NodeTable from persisted B+Tree roots and the next id to hand out (used when reopening a store from its superblock).
Sourcepub fn term_to_id_root(&self) -> Option<PageId>
pub fn term_to_id_root(&self) -> Option<PageId>
Current root page of the term_to_id B+Tree (for superblock persistence).
Sourcepub fn id_to_term_root(&self) -> Option<PageId>
pub fn id_to_term_root(&self) -> Option<PageId>
Current root page of the id_to_term B+Tree (for superblock persistence).
Sourcepub fn next_id_value(&self) -> NodeId
pub fn next_id_value(&self) -> NodeId
Next dictionary NodeId to be allocated (for superblock persistence).
Sourcepub fn compression_stats(&self) -> CompressionStats
pub fn compression_stats(&self) -> CompressionStats
Get prefix compression statistics
Sourcepub fn get_or_create(&self, term: &Term) -> Result<NodeId>
pub fn get_or_create(&self, term: &Term) -> Result<NodeId>
Get or create a NodeId for a term
If the term already exists, returns its NodeId. Otherwise, assigns a new NodeId and stores the mapping.
§Prefix Compression
When prefix compression is enabled and the term is an IRI, the compressor tracks the IRI prefix for statistics. Future versions will use this for actual storage optimization.
Sourcepub fn get_id(&self, term: &Term) -> Result<Option<NodeId>>
pub fn get_id(&self, term: &Term) -> Result<Option<NodeId>>
Get NodeId for a term (returns None if not found)
Sourcepub fn get_term(&self, id: NodeId) -> Result<Option<Term>>
pub fn get_term(&self, id: NodeId) -> Result<Option<Term>>
Get Term for a NodeId (returns None if not found)
Sourcepub fn contains_id(&self, id: NodeId) -> Result<bool>
pub fn contains_id(&self, id: NodeId) -> Result<bool>
Check if a NodeId exists in the dictionary
Auto Trait Implementations§
impl !Freeze for NodeTable
impl !RefUnwindSafe for NodeTable
impl !UnwindSafe for NodeTable
impl Send for NodeTable
impl Sync for NodeTable
impl Unpin for NodeTable
impl UnsafeUnpin for NodeTable
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
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