Struct holmes::mem_db::MemDB
[−]
[src]
pub struct MemDB { /* fields omitted */ }
MemDB is an in-memory mock up of the fact database interface.
While it can be useful for quick tests, it should not be depended on for anything serious, even if you want a standalone app. It is very slow and persists nothing.
MemDB does not currently support projections in any meaninful way. It will treat all projections as though they are simply the next column in sequence for the predicate they are attached to.
Methods
impl MemDB
[src]
Trait Implementations
impl FactDB for MemDB
[src]
type Error = Error
FactDB implementation provided error type
fn new_rule_cache(&self, _preds: Vec<String>) -> Result<CacheId>
Creates a cache table for a new rule, returning a handle
fn cache_hit(&self, cache: CacheId, facts: Vec<FactId>) -> Result<()>
Update
fn insert_fact(&self, fact: &Fact) -> Result<bool>
Adds a new fact to the database, returning false if the fact was already present in the database, and true if it was inserted. Read more
fn add_type(&self, type_: Type) -> Result<()>
Registers a new type with the database. This is unstable, and will likely need to be moved to the initialization of the database object in order to allow reconnecting to an existing database. Read more
fn get_type(&self, type_str: &str) -> Option<Type>
Looks for a named type in the database's registry. This function is primarily useful for the DSL shorthand for constructing queries, since it allows you to use names of types when declaring functions rather than type objects. Read more
fn get_predicate(&self, pred_name: &str) -> Option<Predicate>
Fetches a predicate by name
fn new_predicate(&self, pred: &Predicate) -> Result<()>
Persists a predicate by name
fn search_facts(
&self,
query: &Vec<Clause>,
cache: Option<CacheId>
) -> Result<Vec<(Vec<FactId>, Vec<Value>)>>
&self,
query: &Vec<Clause>,
cache: Option<CacheId>
) -> Result<Vec<(Vec<FactId>, Vec<Value>)>>
Attempt to match the right hand side of a datalog rule against the database, returning a list of solution assignments to the bound variables. Optionally provide a cache handle to have the db filter already processed results based on a provided cache. Read more