Skip to main content

InProgress

Struct InProgress 

Source
pub struct InProgress<'a, 'c> {
    pub transaction: Transaction<'c>,
    pub mutex: &'a Mutex<Metadata>,
    pub generation: u64,
    pub partition_map: PartitionMap,
    pub schema: Schema,
    pub cache: InProgressSQLiteAttributeCache,
    pub use_caching: bool,
    pub tx_observer: &'a Mutex<TxObservationService>,
    pub tx_observer_watcher: InProgressObserverTransactWatcher,
}
Expand description

Represents an in-progress, not yet committed, set of changes to the store. Call commit to commit your changes, or rollback to discard them. A transaction is held open until you do so. Your changes will be implicitly dropped along with this struct.

Fields§

§transaction: Transaction<'c>§mutex: &'a Mutex<Metadata>§generation: u64§partition_map: PartitionMap§schema: Schema§cache: InProgressSQLiteAttributeCache§use_caching: bool§tx_observer: &'a Mutex<TxObservationService>§tx_observer_watcher: InProgressObserverTransactWatcher

Implementations§

Source§

impl<'a, 'c> InProgress<'a, 'c>

Source

pub fn builder(self) -> InProgressBuilder<'a, 'c>

Source

pub fn use_caching(&mut self, yesno: bool)

Choose whether to use in-memory caches for running queries.

Source

pub fn transact_builder( &mut self, builder: TermBuilder, ) -> Result<TxReport, MentatError>

If you only have a reference to an InProgress, you can’t use the easy builder. This exists so you can make your own.

Source

pub fn transact_terms<I>( &mut self, terms: I, tempid_set: InternSet<TempId>, ) -> Result<TxReport, MentatError>

Source

pub fn transact_entities<I, V>( &mut self, entities: I, ) -> Result<TxReport, MentatError>
where V: TransactableValue, I: IntoIterator<Item = Entity<V>>,

Source

pub fn transact<B>(&mut self, transaction: B) -> Result<TxReport, MentatError>
where B: Borrow<str>,

Source

pub fn transact_speculative<B>( &mut self, transaction: B, ) -> Result<TxReport, MentatError>
where B: Borrow<str>,

Speculatively apply an EDN transaction and return its TxReport WITHOUT persisting any changes – the equivalent of Datomic’s d/with and pg_mentat’s mentat.with. Runs the transaction through the exact same code path as a real transact (so tempid resolution, constraint checking and cardinality handling are identical), inside a SAVEPOINT, then rolls back both the SQLite writes and the in-memory partition_map/schema mutations so the InProgress is left exactly as it was.

The returned report’s tx_id, tempids and datoms reflect what would have happened; a subsequent real transact will allocate fresh ids.

Source

pub fn transact_entities_speculative<I, V>( &mut self, entities: I, ) -> Result<TxReport, MentatError>
where V: TransactableValue, I: IntoIterator<Item = Entity<V>>,

Entity-level speculative transact. See [transact_speculative].

Source

pub fn import<P>(&mut self, path: P) -> Result<TxReport, MentatError>
where P: AsRef<Path>,

Source

pub fn rollback(self) -> Result<(), MentatError>

Source

pub fn commit(self) -> Result<(), MentatError>

Source

pub fn cache( &mut self, attribute: &Keyword, cache_direction: CacheDirection, cache_action: CacheAction, ) -> Result<(), MentatError>

Source

pub fn last_tx_id(&self) -> i64

Source

pub fn savepoint(&self, name: &str) -> Result<(), MentatError>

Source

pub fn rollback_savepoint(&self, name: &str) -> Result<(), MentatError>

Source

pub fn release_savepoint(&self, name: &str) -> Result<(), MentatError>

Trait Implementations§

Source§

impl<'a, 'c> HasSchema for InProgress<'a, 'c>

Source§

fn is_attribute<T>(&self, x: T) -> bool
where T: Into<i64>,

Return true if the provided entid identifies an attribute in this schema.

Source§

fn identifies_attribute(&self, x: &Keyword) -> bool

Return true if the provided ident identifies an attribute in this schema.

Source§

fn entid_for_type(&self, t: ValueType) -> Option<KnownEntid>

Source§

fn get_ident<T>(&self, x: T) -> Option<&Keyword>
where T: Into<i64>,

Source§

fn get_entid(&self, x: &Keyword) -> Option<KnownEntid>

Source§

fn attribute_for_entid<T>(&self, x: T) -> Option<&Attribute>
where T: Into<i64>,

Source§

fn attribute_for_ident( &self, ident: &Keyword, ) -> Option<(&Attribute, KnownEntid)>

Source§

fn component_attributes(&self) -> &[i64]

Source§

impl<'a, 'c> Pullable for InProgress<'a, 'c>

Source§

fn pull_attributes_for_entities<E, A>( &self, entities: E, attributes: A, ) -> Result<BTreeMap<i64, Arc<StructuredMap>>, MentatError>
where E: IntoIterator<Item = i64>, A: IntoIterator<Item = i64>,

Source§

fn pull_attributes_for_entity<A>( &self, entity: i64, attributes: A, ) -> Result<StructuredMap, MentatError>
where A: IntoIterator<Item = i64>,

Source§

impl<'a, 'c> Queryable for InProgress<'a, 'c>

Source§

fn q_once<T>(&self, query: &str, inputs: T) -> Result<QueryOutput, MentatError>
where T: Into<Option<QueryInputs>>,

Source§

fn q_prepare<T>( &self, query: &str, inputs: T, ) -> Result<PreparedQuery<'_>, MentatError>
where T: Into<Option<QueryInputs>>,

Source§

fn q_explain<T>( &self, query: &str, inputs: T, ) -> Result<QueryExplanation, MentatError>
where T: Into<Option<QueryInputs>>,

Source§

fn lookup_values_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Vec<TypedValue>, MentatError>
where E: Into<i64>,

Source§

fn lookup_value_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Option<TypedValue>, MentatError>
where E: Into<i64>,

Source§

impl VersionedStore for InProgress<'_, '_>

Source§

fn ensure_vocabulary( &mut self, definition: &Definition, ) -> Result<VocabularyOutcome>

Check whether the provided vocabulary is present in the store. If it isn’t, make it so.
Source§

fn ensure_vocabularies( &mut self, vocabularies: &mut dyn VocabularySource, ) -> Result<BTreeMap<Keyword, VocabularyOutcome>>

Check whether the provided vocabularies are present in the store at the correct version and with all defined attributes. If any are not, invoke the pre function on the provided VocabularySource, install or upgrade the necessary vocabularies, then invoke post. Returns Ok if all of these steps succeed. Read more
Source§

fn check_vocabulary<'definition>( &self, definition: &'definition Definition, ) -> Result<VocabularyCheck<'definition>>

Check whether the vocabulary described by the provided metadata is present in the store.
Source§

fn verify_core_schema(&self) -> Result<()>

Make sure that our expectations of the core vocabulary — basic types and attributes — are met.

Auto Trait Implementations§

§

impl<'a, 'c> !RefUnwindSafe for InProgress<'a, 'c>

§

impl<'a, 'c> !Send for InProgress<'a, 'c>

§

impl<'a, 'c> !Sync for InProgress<'a, 'c>

§

impl<'a, 'c> !UnwindSafe for InProgress<'a, 'c>

§

impl<'a, 'c> Freeze for InProgress<'a, 'c>

§

impl<'a, 'c> Unpin for InProgress<'a, 'c>

§

impl<'a, 'c> UnsafeUnpin for InProgress<'a, 'c>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HasVocabularies for T
where T: HasSchema + Queryable,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.