pub struct TemporalKnowledgeGraph { /* private fields */ }Expand description
An in-memory knowledge graph that stores triples with temporal validity.
Internally, triples are stored in a Vec and a secondary BTreeMap index
maps valid_from timestamps to the indices of triples that start at that
timestamp. This allows efficient range scans over the time axis.
Implementations§
Source§impl TemporalKnowledgeGraph
impl TemporalKnowledgeGraph
Sourcepub fn insert(&mut self, triple: TemporalTriple)
pub fn insert(&mut self, triple: TemporalTriple)
Insert a temporal triple and update the time index.
Sourcepub fn query_at(&self, timestamp: i64) -> Vec<&TemporalTriple>
pub fn query_at(&self, timestamp: i64) -> Vec<&TemporalTriple>
Return all triples that are valid at timestamp.
Sourcepub fn query_range(&self, from: i64, to: i64) -> Vec<&TemporalTriple>
pub fn query_range(&self, from: i64, to: i64) -> Vec<&TemporalTriple>
Return all triples whose validity interval overlaps [from, to).
Sourcepub fn entities_at(&self, timestamp: i64) -> HashSet<String>
pub fn entities_at(&self, timestamp: i64) -> HashSet<String>
Return the set of entity identifiers (subjects and objects) that appear
in at least one valid triple at timestamp.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TemporalKnowledgeGraph
impl RefUnwindSafe for TemporalKnowledgeGraph
impl Send for TemporalKnowledgeGraph
impl Sync for TemporalKnowledgeGraph
impl Unpin for TemporalKnowledgeGraph
impl UnsafeUnpin for TemporalKnowledgeGraph
impl UnwindSafe for TemporalKnowledgeGraph
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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