[−][src]Trait terminus_store::layer::layer::Layer
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 name(&self) -> [u32; 5]
The name of this layer
fn parent(&self) -> Option<Arc<dyn Layer>>
The parent of this layer, or None if this is a base layer
fn node_and_value_count(&self) -> usize
The amount of nodes and values known to this layer This also counts entries in the parent.
fn predicate_count(&self) -> usize
The amount of predicates known to this layer This also counts entries in the parent.
fn subject_id(&self, subject: &str) -> Option<u64>
The numerical id of a subject, or None if the subject cannot be found
fn predicate_id(&self, predicate: &str) -> Option<u64>
The numerical id of a predicate, or None if the predicate cannot be found
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
fn object_value_id(&self, object: &str) -> Option<u64>
The numerical id of a value object, or None if the value object cannot be found
fn id_subject(&self, id: u64) -> Option<String>
The subject corresponding to a numerical id, or None if it cannot be found
fn id_predicate(&self, id: u64) -> Option<String>
The predicate corresponding to a numerical id, or None if it cannot be found
fn id_object(&self, id: u64) -> Option<ObjectType>
The object corresponding to a numerical id, or None if it cannot be found
fn subjects(&self) -> Box<dyn Iterator<Item = Box<dyn SubjectLookup>>>
Returns an iterator over all triple data known to this layer
This data is returned by
SubjectLookup
. Each such object stores a
subject id, and knows how to retrieve any linked
predicate-object pair.
fn lookup_subject(&self, subject: u64) -> Option<Box<dyn SubjectLookup>>
Returns a SubjectLookup
object for the given subject, or None if it cannot be constructed
Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given subject. All it means is that this layer or a parent layer has registered an addition involving this subject. However, later layers may have then removed every triple involving this subject.
fn objects(&self) -> Box<dyn Iterator<Item = Box<dyn ObjectLookup>>>
Returns an iterator over all objects known to this layer.
Objects are returned as an ObjectLookup
, an object that can
then be queried for subject-predicate pairs pointing to that
object.
fn lookup_object(&self, object: u64) -> Option<Box<dyn ObjectLookup>>
Returns an ObjectLookup
for the given object, or None if it could not be constructed
Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given object. All it means is that this layer or a parent layer has registered an addition involving this object. However, later layers may have then removed every triple involving this object.
Provided methods
fn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool
Returns true if the given triple exists, and false otherwise
fn id_triple_exists(&self, triple: IdTriple) -> bool
Returns true if the given triple exists, and false otherwise
fn string_triple_exists(&self, triple: &StringTriple) -> bool
Returns true if the given triple exists, and false otherwise
fn triples(&self) -> Box<dyn Iterator<Item = IdTriple>>
Iterator over all triples known to this layer.
This is a convenient werapper around
SubjectLookup
and
SubjectPredicateLookup
style querying.
fn string_triple_to_id(&self, triple: &StringTriple) -> Option<IdTriple>
fn string_triple_to_partially_resolved(
&self,
triple: &StringTriple
) -> PartiallyResolvedTriple
&self,
triple: &StringTriple
) -> PartiallyResolvedTriple
Convert all known strings in the given string triple to ids
fn id_triple_to_string(&self, triple: &IdTriple) -> Option<StringTriple>
Convert an id triple to the corresponding string version, returning None if any of those ids could not be converted
fn is_ancestor_of(&self, other: &dyn Layer) -> bool
Returns true if the given layer is an ancestor of this layer, false otherwise