Skip to main content

CommandTransaction

Struct CommandTransaction 

Source
pub struct CommandTransaction {
    pub multi: MultiTransaction,
    pub single: SingleTransaction,
    pub cmd: Option<MultiWriteTransaction>,
    pub event_bus: EventBus,
    pub testing: Option<TestingContext>,
    /* private fields */
}
Expand description

An active command transaction that holds a multi command transaction and provides query/command access to single storage.

The transaction will auto-rollback on drop if not explicitly committed.

Fields§

§multi: MultiTransaction§single: SingleTransaction§cmd: Option<MultiWriteTransaction>§event_bus: EventBus§testing: Option<TestingContext>

Testing audit log. Set by the VM when in test context.

Implementations§

Source§

impl CommandTransaction

Source

pub fn new( multi: MultiTransaction, single: SingleTransaction, event_bus: EventBus, interceptors: Interceptors, ) -> Result<Self>

Creates a new active command transaction with a pre-commit callback

Source

pub fn event_bus(&self) -> &EventBus

Source

pub fn commit(&mut self) -> Result<CommitVersion>

Commit the transaction. Since single transactions are short-lived and auto-commit, this only commits the multi transaction.

Source

pub fn rollback(&mut self) -> Result<()>

Rollback the transaction.

Source

pub fn pending_writes(&self) -> &PendingWrites

Get access to the pending writes in this transaction

This allows checking for key conflicts when committing FlowTransactions to ensure they operate on non-overlapping keyspaces.

Source

pub fn with_single_query<'a, I, F, R>(&self, keys: I, f: F) -> Result<R>
where I: IntoIterator<Item = &'a EncodedKey> + Send, F: FnOnce(&mut SingleReadTransaction<'_>) -> Result<R> + Send, R: Send,

Execute a function with query access to the single transaction.

Source

pub fn with_single_command<'a, I, F, R>(&self, keys: I, f: F) -> Result<R>
where I: IntoIterator<Item = &'a EncodedKey> + Send, F: FnOnce(&mut SingleWriteTransaction<'_>) -> Result<R> + Send, R: Send,

Execute a function with query access to the single transaction.

Source

pub fn with_multi_query<F, R>(&self, f: F) -> Result<R>
where F: FnOnce(&mut QueryTransaction) -> Result<R>,

Execute a function with a query transaction view. This creates a new query transaction using the stored multi-version storage. The query transaction will operate independently but share the same single/CDC storage.

Source

pub fn with_multi_query_as_of_exclusive<F, R>( &self, version: CommitVersion, f: F, ) -> Result<R>
where F: FnOnce(&mut QueryTransaction) -> Result<R>,

Source

pub fn with_multi_query_as_of_inclusive<F, R>( &self, version: CommitVersion, f: F, ) -> Result<R>
where F: FnOnce(&mut QueryTransaction) -> Result<R>,

Source

pub fn begin_single_query<'a, I>( &self, keys: I, ) -> Result<SingleReadTransaction<'_>>
where I: IntoIterator<Item = &'a EncodedKey>,

Begin a single-version query transaction for specific keys

Source

pub fn begin_single_command<'a, I>( &self, keys: I, ) -> Result<SingleWriteTransaction<'_>>
where I: IntoIterator<Item = &'a EncodedKey>,

Begin a single-version command transaction for specific keys

Source

pub fn track_row_change(&mut self, change: RowChange)

Track a row change for post-commit event emission

Source

pub fn track_flow_change(&mut self, change: Change)

Track a flow change for transactional view pre-commit processing

Source

pub fn version(&self) -> CommitVersion

Get the transaction version

Source

pub fn id(&self) -> TransactionId

Get the transaction ID

Source

pub fn get(&mut self, key: &EncodedKey) -> Result<Option<MultiVersionValues>>

Get a value by key

Source

pub fn contains_key(&mut self, key: &EncodedKey) -> Result<bool>

Check if a key exists

Source

pub fn prefix(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>

Get a prefix batch

Source

pub fn prefix_rev(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>

Get a reverse prefix batch

Source

pub fn read_as_of_version_exclusive( &mut self, version: CommitVersion, ) -> Result<()>

Read as of version exclusive

Source

pub fn set(&mut self, key: &EncodedKey, row: EncodedValues) -> Result<()>

Set a key-value pair

Source

pub fn unset(&mut self, key: &EncodedKey, values: EncodedValues) -> Result<()>

Unset a key, preserving the deleted values.

The values parameter contains the deleted values for CDC and metrics.

Source

pub fn remove(&mut self, key: &EncodedKey) -> Result<()>

Remove a key without preserving the deleted values.

Use when only the key matters (e.g., index entries, catalog metadata).

Source

pub fn range( &mut self, range: EncodedKeyRange, batch_size: usize, ) -> Result<Box<dyn Iterator<Item = Result<MultiVersionValues>> + Send + '_>>

Create a streaming iterator for forward range queries.

Source

pub fn range_rev( &mut self, range: EncodedKeyRange, batch_size: usize, ) -> Result<Box<dyn Iterator<Item = Result<MultiVersionValues>> + Send + '_>>

Create a streaming iterator for reverse range queries.

Trait Implementations§

Source§

impl Drop for CommandTransaction

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> From<&'a mut CommandTransaction> for Transaction<'a>

Source§

fn from(txn: &'a mut CommandTransaction) -> Self

Converts to this type from the input type.
Source§

impl WithEventBus for CommandTransaction

Source§

impl WithInterceptors for CommandTransaction

Source§

fn table_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn TablePreInsertInterceptor + Send + Sync>

Access table pre-insert interceptor chain
Source§

fn table_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn TablePostInsertInterceptor + Send + Sync>

Access table post-insert interceptor chain
Source§

fn table_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn TablePreUpdateInterceptor + Send + Sync>

Access table pre-update interceptor chain
Source§

fn table_post_update_interceptors( &mut self, ) -> &mut Chain<dyn TablePostUpdateInterceptor + Send + Sync>

Access table post-update interceptor chain
Source§

fn table_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn TablePreDeleteInterceptor + Send + Sync>

Access table pre-delete interceptor chain
Source§

fn table_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn TablePostDeleteInterceptor + Send + Sync>

Access table post-delete interceptor chain
Source§

fn ringbuffer_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreInsertInterceptor + Send + Sync>

Access ring buffer pre-insert interceptor chain
Source§

fn ringbuffer_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostInsertInterceptor + Send + Sync>

Access ring buffer post-insert interceptor chain
Source§

fn ringbuffer_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreUpdateInterceptor + Send + Sync>

Access ring buffer pre-update interceptor chain
Source§

fn ringbuffer_post_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostUpdateInterceptor + Send + Sync>

Access ring buffer post-update interceptor chain
Source§

fn ringbuffer_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreDeleteInterceptor + Send + Sync>

Access ring buffer pre-delete interceptor chain
Source§

fn ringbuffer_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostDeleteInterceptor + Send + Sync>

Access ring buffer post-delete interceptor chain
Source§

fn pre_commit_interceptors( &mut self, ) -> &mut Chain<dyn PreCommitInterceptor + Send + Sync>

Access pre-commit interceptor chain
Source§

fn post_commit_interceptors( &mut self, ) -> &mut Chain<dyn PostCommitInterceptor + Send + Sync>

Access post-commit interceptor chain
Source§

fn namespace_post_create_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePostCreateInterceptor + Send + Sync>

Access namespace post-create interceptor chain
Source§

fn namespace_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePreUpdateInterceptor + Send + Sync>

Access namespace pre-update interceptor chain
Source§

fn namespace_post_update_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePostUpdateInterceptor + Send + Sync>

Access namespace post-update interceptor chain
Source§

fn namespace_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePreDeleteInterceptor + Send + Sync>

Access namespace pre-delete interceptor chain
Source§

fn table_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPostCreateInterceptor + Send + Sync>

Access table definition post-create interceptor chain
Source§

fn table_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPreUpdateInterceptor + Send + Sync>

Access table definition pre-update interceptor chain
Source§

fn table_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPostUpdateInterceptor + Send + Sync>

Access table definition post-update interceptor chain
Source§

fn table_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPreDeleteInterceptor + Send + Sync>

Access table definition pre-delete interceptor chain
Source§

fn view_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreInsertInterceptor + Send + Sync>

Access view pre-insert interceptor chain
Source§

fn view_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostInsertInterceptor + Send + Sync>

Access view post-insert interceptor chain
Source§

fn view_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreUpdateInterceptor + Send + Sync>

Access view pre-update interceptor chain
Source§

fn view_post_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostUpdateInterceptor + Send + Sync>

Access view post-update interceptor chain
Source§

fn view_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreDeleteInterceptor + Send + Sync>

Access view pre-delete interceptor chain
Source§

fn view_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostDeleteInterceptor + Send + Sync>

Access view post-delete interceptor chain
Source§

fn view_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPostCreateInterceptor + Send + Sync>

Access view post-create interceptor chain
Source§

fn view_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPreUpdateInterceptor + Send + Sync>

Access view pre-update interceptor chain
Source§

fn view_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPostUpdateInterceptor + Send + Sync>

Access view post-update interceptor chain
Source§

fn view_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPreDeleteInterceptor + Send + Sync>

Access view pre-delete interceptor chain
Source§

fn ringbuffer_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPostCreateInterceptor + Send + Sync>

Access ring buffer definition post-create interceptor chain
Source§

fn ringbuffer_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPreUpdateInterceptor + Send + Sync>

Access ring buffer definition pre-update interceptor chain
Source§

fn ringbuffer_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPostUpdateInterceptor + Send + Sync>

Access ring buffer definition post-update interceptor chain
Source§

fn ringbuffer_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPreDeleteInterceptor + Send + Sync>

Access ring buffer definition pre-delete interceptor chain

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more