Trait terminus_store::Layer
source · pub trait Layer: Send + Sync {
Show 32 methods
// Required methods
fn name(&self) -> [u32; 5];
fn parent_name(&self) -> Option<[u32; 5]>;
fn node_and_value_count(&self) -> usize;
fn predicate_count(&self) -> usize;
fn subject_id(&self, subject: &str) -> Option<u64>;
fn predicate_id(&self, predicate: &str) -> Option<u64>;
fn object_node_id(&self, object: &str) -> Option<u64>;
fn object_value_id(&self, object: &TypedDictEntry) -> Option<u64>;
fn id_subject(&self, id: u64) -> Option<String>;
fn id_predicate(&self, id: u64) -> Option<String>;
fn id_object(&self, id: u64) -> Option<ObjectType>;
fn id_object_is_node(&self, id: u64) -> Option<bool>;
fn all_counts(&self) -> LayerCounts;
fn clone_boxed(&self) -> Box<dyn Layer>;
fn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool;
fn triples(&self) -> Box<dyn Iterator<Item = IdTriple> + Send>;
fn triples_s(
&self,
subject: u64
) -> Box<dyn Iterator<Item = IdTriple> + Send>;
fn triples_sp(
&self,
subject: u64,
predicate: u64
) -> Box<dyn Iterator<Item = IdTriple> + Send>;
fn triples_p(
&self,
predicate: u64
) -> Box<dyn Iterator<Item = IdTriple> + Send>;
fn triples_o(
&self,
object: u64
) -> Box<dyn Iterator<Item = IdTriple> + Send>;
fn triple_addition_count(&self) -> usize;
fn triple_removal_count(&self) -> usize;
fn single_triple_sp(&self, subject: u64, predicate: u64) -> Option<IdTriple>;
// Provided methods
fn id_object_node(&self, id: u64) -> Option<String> { ... }
fn id_object_value(&self, id: u64) -> Option<TypedDictEntry> { ... }
fn id_object_is_value(&self, id: u64) -> Option<bool> { ... }
fn id_triple_exists(&self, triple: IdTriple) -> bool { ... }
fn value_triple_exists(&self, triple: &ValueTriple) -> bool { ... }
fn value_triple_to_id(&self, triple: &ValueTriple) -> Option<IdTriple> { ... }
fn value_triple_to_partially_resolved(
&self,
triple: ValueTriple
) -> PartiallyResolvedTriple { ... }
fn id_triple_to_string(&self, triple: &IdTriple) -> Option<ValueTriple> { ... }
fn triple_count(&self) -> usize { ... }
}
Expand description
A layer containing dictionary entries and triples.
A layer can be queried. To answer queries, layers will check their own data structures, and if they have a parent, the parent is queried as well.
Required Methods§
fn parent_name(&self) -> Option<[u32; 5]>
sourcefn node_and_value_count(&self) -> usize
fn node_and_value_count(&self) -> usize
The amount of nodes and values known to this layer. This also counts entries in the parent.
sourcefn predicate_count(&self) -> usize
fn predicate_count(&self) -> usize
The amount of predicates known to this layer. This also counts entries in the parent.
sourcefn subject_id(&self, subject: &str) -> Option<u64>
fn subject_id(&self, subject: &str) -> Option<u64>
The numerical id of a subject, or None if the subject cannot be found.
sourcefn predicate_id(&self, predicate: &str) -> Option<u64>
fn predicate_id(&self, predicate: &str) -> Option<u64>
The numerical id of a predicate, or None if the predicate cannot be found.
sourcefn object_node_id(&self, object: &str) -> Option<u64>
fn object_node_id(&self, object: &str) -> Option<u64>
The numerical id of a node object, or None if the node object cannot be found.
sourcefn object_value_id(&self, object: &TypedDictEntry) -> Option<u64>
fn object_value_id(&self, object: &TypedDictEntry) -> Option<u64>
The numerical id of a value object, or None if the value object cannot be found.
sourcefn id_subject(&self, id: u64) -> Option<String>
fn id_subject(&self, id: u64) -> Option<String>
The subject corresponding to a numerical id, or None if it cannot be found.
sourcefn id_predicate(&self, id: u64) -> Option<String>
fn id_predicate(&self, id: u64) -> Option<String>
The predicate corresponding to a numerical id, or None if it cannot be found.
sourcefn id_object(&self, id: u64) -> Option<ObjectType>
fn id_object(&self, id: u64) -> Option<ObjectType>
The object corresponding to a numerical id, or None if it cannot be found.
sourcefn id_object_is_node(&self, id: u64) -> Option<bool>
fn id_object_is_node(&self, id: u64) -> Option<bool>
Check if the given id refers to a node.
This will return None if the id doesn’t refer to anything.
sourcefn all_counts(&self) -> LayerCounts
fn all_counts(&self) -> LayerCounts
Create a struct with all the counts
sourcefn clone_boxed(&self) -> Box<dyn Layer>
fn clone_boxed(&self) -> Box<dyn Layer>
Return a clone of this layer in a box.
sourcefn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool
fn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool
Returns true if the given triple exists, and false otherwise.
sourcefn triples(&self) -> Box<dyn Iterator<Item = IdTriple> + Send>
fn triples(&self) -> Box<dyn Iterator<Item = IdTriple> + Send>
Iterator over all triples known to this layer.
fn triples_s(&self, subject: u64) -> Box<dyn Iterator<Item = IdTriple> + Send>
fn triples_sp( &self, subject: u64, predicate: u64 ) -> Box<dyn Iterator<Item = IdTriple> + Send>
fn triples_p(&self, predicate: u64) -> Box<dyn Iterator<Item = IdTriple> + Send>
fn triples_o(&self, object: u64) -> Box<dyn Iterator<Item = IdTriple> + Send>
sourcefn triple_addition_count(&self) -> usize
fn triple_addition_count(&self) -> usize
Returns the total amount of triple additions in this layer and all its parents.
sourcefn triple_removal_count(&self) -> usize
fn triple_removal_count(&self) -> usize
Returns the total amount of triple removals in this layer and all its parents.
fn single_triple_sp(&self, subject: u64, predicate: u64) -> Option<IdTriple>
Provided Methods§
sourcefn id_object_node(&self, id: u64) -> Option<String>
fn id_object_node(&self, id: u64) -> Option<String>
The object node corresponding to a numerical id, or None if it cannot be found. Panics if the object is actually a value.
sourcefn id_object_value(&self, id: u64) -> Option<TypedDictEntry>
fn id_object_value(&self, id: u64) -> Option<TypedDictEntry>
The object value corresponding to a numerical id, or None if it cannot be found. Panics if the object is actually a node.
sourcefn id_object_is_value(&self, id: u64) -> Option<bool>
fn id_object_is_value(&self, id: u64) -> Option<bool>
Check if the given id refers to a value.
This will return None if the id doesn’t refer to anything.
sourcefn id_triple_exists(&self, triple: IdTriple) -> bool
fn id_triple_exists(&self, triple: IdTriple) -> bool
Returns true if the given triple exists, and false otherwise.
sourcefn value_triple_exists(&self, triple: &ValueTriple) -> bool
fn value_triple_exists(&self, triple: &ValueTriple) -> bool
Returns true if the given triple exists, and false otherwise.
sourcefn value_triple_to_id(&self, triple: &ValueTriple) -> Option<IdTriple>
fn value_triple_to_id(&self, triple: &ValueTriple) -> Option<IdTriple>
Convert a ValueTriple
to an IdTriple
, returning None if any of the strings in the triple could not be resolved.
sourcefn value_triple_to_partially_resolved(
&self,
triple: ValueTriple
) -> PartiallyResolvedTriple
fn value_triple_to_partially_resolved( &self, triple: ValueTriple ) -> PartiallyResolvedTriple
Convert all known strings in the given string triple to ids.
sourcefn id_triple_to_string(&self, triple: &IdTriple) -> Option<ValueTriple>
fn id_triple_to_string(&self, triple: &IdTriple) -> Option<ValueTriple>
Convert an id triple to the corresponding string version, returning None if any of those ids could not be converted.
sourcefn triple_count(&self) -> usize
fn triple_count(&self) -> usize
Returns the total amount of triples in this layer and all its parents.