Trait mentat_db::db::MentatStoring
[−]
[src]
pub trait MentatStoring { fn resolve_avs<'a>(&self, avs: &'a [&'a AVPair]) -> Result<AVMap<'a>>; fn begin_tx_application(&self) -> Result<()>; fn insert_non_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>; fn insert_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>; fn materialize_mentat_transaction(&self, tx_id: Entid) -> Result<()>; fn commit_mentat_transaction(&self, tx_id: Entid) -> Result<()>; fn resolved_metadata_assertions(
&self
) -> Result<Vec<(Entid, Entid, TypedValue, bool)>>; }
MentatStoring
will be the trait that encapsulates the storage layer. It is consumed by the
transaction processing layer.
Right now, the only implementation of MentatStoring
is the SQLite-specific SQL schema. In the
future, we might consider other SQL engines (perhaps with different fulltext indexing), or
entirely different data stores, say ones shaped like key-value stores.
Required Methods
fn resolve_avs<'a>(&self, avs: &'a [&'a AVPair]) -> Result<AVMap<'a>>
Given a slice of [a v] lookup-refs, look up the corresponding [e a v] triples.
It is assumed that the attribute a
in each lookup-ref is :db/unique
, so that at most one
matching [e a v] triple exists. (If this is not true, some matching entid e
will be
chosen non-deterministically, if one exists.)
Returns a map &(a, v) -> e, to avoid cloning potentially large values. The keys of the map are exactly those (a, v) pairs that have an assertion [e a v] in the store.
fn begin_tx_application(&self) -> Result<()>
Begin (or prepare) the underlying storage layer for a new Mentat transaction.
Use this to create temporary tables, prepare indices, set pragmas, etc, before the initial
insert_non_fts_searches
invocation.
fn insert_non_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>
fn insert_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>
&self,
entities: &'a [ReducedEntity],
search_type: SearchType
) -> Result<()>
fn materialize_mentat_transaction(&self, tx_id: Entid) -> Result<()>
Prepare the underlying storage layer for finalization after a Mentat transaction.
Use this to finalize temporary tables, complete indices, revert pragmas, etc, after the
final insert_non_fts_searches
invocation.
fn commit_mentat_transaction(&self, tx_id: Entid) -> Result<()>
Finalize the underlying storage layer after a Mentat transaction.
This is a final step in performing a transaction.
fn resolved_metadata_assertions(
&self
) -> Result<Vec<(Entid, Entid, TypedValue, bool)>>
&self
) -> Result<Vec<(Entid, Entid, TypedValue, bool)>>
Extract metadata-related [e a typed_value added] datoms resolved in the last materialized transaction.
Implementations on Foreign Types
impl MentatStoring for Connection
[src]
fn resolve_avs<'a>(&self, avs: &'a [&'a AVPair]) -> Result<AVMap<'a>>
[src]
fn begin_tx_application(&self) -> Result<()>
[src]
Create empty temporary tables for search parameters and search results.
fn insert_non_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity<'a>],
search_type: SearchType
) -> Result<()>
[src]
&self,
entities: &'a [ReducedEntity<'a>],
search_type: SearchType
) -> Result<()>
Insert search rows into temporary search tables.
Eventually, the details of this approach will be captured in https://github.com/mozilla/mentat/wiki/Transacting:-entity-to-SQL-translation.
fn insert_fts_searches<'a>(
&self,
entities: &'a [ReducedEntity<'a>],
search_type: SearchType
) -> Result<()>
[src]
&self,
entities: &'a [ReducedEntity<'a>],
search_type: SearchType
) -> Result<()>
Insert search rows into temporary search tables.
Eventually, the details of this approach will be captured in https://github.com/mozilla/mentat/wiki/Transacting:-entity-to-SQL-translation.
fn commit_mentat_transaction(&self, tx_id: Entid) -> Result<()>
[src]
fn materialize_mentat_transaction(&self, tx_id: Entid) -> Result<()>
[src]
fn resolved_metadata_assertions(
&self
) -> Result<Vec<(Entid, Entid, TypedValue, bool)>>
[src]
&self
) -> Result<Vec<(Entid, Entid, TypedValue, bool)>>