pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
Sourcepub fn open(path: &str) -> Result<Store>
pub fn open(path: &str) -> Result<Store>
Open a store at the supplied path, ensuring that it includes the bootstrap schema.
pub fn transact(&mut self, transaction: &str) -> Result<TxReport>
Sourcepub fn expand_tx_fns(&mut self, transaction: &str) -> Result<String>
pub fn expand_tx_fns(&mut self, transaction: &str) -> Result<String>
Prepare transaction for the transactor: replace every invocation of a
user-defined transaction function ([:my/fn arg ...] on an ident that
carries :db/fn) with the tx-data it returns, and define the :db/fn
attribute itself the first time a transaction installs a function.
Store::transact and Store::with_speculative call this; a host
that drives InProgress::transact directly calls it first.
Functions run in the sandboxed mino interpreter (mino feature), see
the database as of the start of the transaction, and nest at most
MENTAT_TXFN_MAX_DEPTH (default 16) deep. Without the mino feature
only the :db/fn attribute bootstrap applies.
Sourcepub fn with_speculative(&mut self, transaction: &str) -> Result<TxReport>
pub fn with_speculative(&mut self, transaction: &str) -> Result<TxReport>
Speculatively transact transaction and return its TxReport WITHOUT
committing (Datomic d/with). Delegates to Conn::transact_speculative,
which opens a real SQLite transaction and rolls it back on drop, so the
store is left unchanged. This is the thin &mut Store wrapper the
scripting layer needs, since transact_speculative lives on Conn and
wants both the Conn and the rusqlite::Connection (both private here).
Source§impl Store
impl Store
Sourcepub fn sqlite_mut(&mut self) -> &mut Connection
pub fn sqlite_mut(&mut self) -> &mut Connection
Intended for use from tests.
Sourcepub fn sqlite_ref(&self) -> &Connection
pub fn sqlite_ref(&self) -> &Connection
A shared borrow of the underlying SQLite connection, for read-only
helpers (e.g. mentat_db::debug::datoms) that only need &Connection.
Source§impl Store
impl Store
pub fn dismantle(self) -> (Connection, Conn)
pub fn conn(&self) -> &Conn
pub fn begin_read(&mut self) -> Result<InProgressRead<'_, '_>>
pub fn begin_transaction(&mut self) -> Result<InProgress<'_, '_>>
pub fn cache(&mut self, attr: &Keyword, direction: CacheDirection) -> Result<()>
pub fn register_observer(&mut self, key: String, observer: Arc<TxObserver>)
pub fn unregister_observer(&mut self, key: &str)
pub fn last_tx_id(&self) -> Entid
Sourcepub fn set_auto_index(&mut self, mode: AutoIndex)
pub fn set_auto_index(&mut self, mode: AutoIndex)
How mentat manages secondary indexes for this Store (see AutoIndex).
The default comes from MENTAT_AUTO_INDEX (off/schema/adaptive),
else Schema.
Sourcepub fn set_index_tuning(&mut self, min_uses: u32, idle: Duration)
pub fn set_index_tuning(&mut self, min_uses: u32, idle: Duration)
Adaptive thresholds: create an index once an attribute is value-filtered
by min_uses queries within one tuning period; drop a mentat-created
index unused for a whole period and for at least idle.
Sourcepub fn tune_indexes(&mut self, dry_run: bool) -> Result<Vec<IndexAction>>
pub fn tune_indexes(&mut self, dry_run: bool) -> Result<Vec<IndexAction>>
Apply (or, with dry_run, only report) index changes per the current
AutoIndex mode. Only ever drops indexes mentat
created (listed in mentat_managed_indexes).
Sourcepub fn q_once_as_of<T>(
&self,
query: &str,
inputs: T,
tx: Entid,
) -> Result<QueryOutput>
pub fn q_once_as_of<T>( &self, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
Run a Datalog query against a historical basis reconstructed as of
transaction tx (inclusive) – the state that was current at tx.
Sourcepub fn q_explain_temporal<T>(
&self,
query: &str,
inputs: T,
temporal: Option<TemporalBound>,
) -> Result<QueryExplanation>
pub fn q_explain_temporal<T>( &self, query: &str, inputs: T, temporal: Option<TemporalBound>, ) -> Result<QueryExplanation>
EXPLAIN QUERY PLAN for a query, optionally against a historical basis.
Sourcepub fn q_once_since<T>(
&self,
query: &str,
inputs: T,
tx: Entid,
) -> Result<QueryOutput>
pub fn q_once_since<T>( &self, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
Run a Datalog query seeing only datoms transacted after transaction tx
(since). Typically used with a history pattern [?e ?a ?v ?tx ?added].
Trait Implementations§
Source§impl Pullable for Store
impl Pullable for Store
fn pull_attributes_for_entities<E, A>( &self, entities: E, attributes: A, ) -> Result<BTreeMap<Entid, ValueRc<StructuredMap>>>
fn pull_attributes_for_entity<A>(
&self,
entity: Entid,
attributes: A,
) -> Result<StructuredMap>where
A: IntoIterator<Item = Entid>,
Source§impl Queryable for Store
impl Queryable for Store
fn q_once<T>(&self, query: &str, inputs: T) -> Result<QueryOutput>
fn q_prepare<T>(&self, query: &str, inputs: T) -> PreparedResult<'_>
fn q_explain<T>(&self, query: &str, inputs: T) -> Result<QueryExplanation>
fn lookup_values_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Vec<TypedValue>>
fn lookup_value_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Option<TypedValue>>
Auto Trait Implementations§
impl !Freeze for Store
impl !RefUnwindSafe for Store
impl !Sync for Store
impl !UnwindSafe for Store
impl Send for Store
impl Unpin for Store
impl UnsafeUnpin for Store
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
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> ⓘ
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> ⓘ
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