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
impl CommandTransaction
Sourcepub fn new(
multi: MultiTransaction,
single: SingleTransaction,
event_bus: EventBus,
interceptors: Interceptors,
) -> Result<Self>
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
pub fn event_bus(&self) -> &EventBus
Sourcepub fn commit(&mut self) -> Result<CommitVersion>
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.
Sourcepub fn pending_writes(&self) -> &PendingWrites
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.
Sourcepub 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,
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.
Sourcepub 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,
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.
Sourcepub fn with_multi_query<F, R>(&self, f: F) -> Result<R>
pub fn with_multi_query<F, R>(&self, f: F) -> 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.
pub fn with_multi_query_as_of_exclusive<F, R>( &self, version: CommitVersion, f: F, ) -> Result<R>
pub fn with_multi_query_as_of_inclusive<F, R>( &self, version: CommitVersion, f: F, ) -> Result<R>
Sourcepub fn begin_single_query<'a, I>(
&self,
keys: I,
) -> Result<SingleReadTransaction<'_>>where
I: IntoIterator<Item = &'a EncodedKey>,
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
Sourcepub fn begin_single_command<'a, I>(
&self,
keys: I,
) -> Result<SingleWriteTransaction<'_>>where
I: IntoIterator<Item = &'a EncodedKey>,
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
Sourcepub fn track_row_change(&mut self, change: RowChange)
pub fn track_row_change(&mut self, change: RowChange)
Track a row change for post-commit event emission
Sourcepub fn track_flow_change(&mut self, change: Change)
pub fn track_flow_change(&mut self, change: Change)
Track a flow change for transactional view pre-commit processing
Sourcepub fn version(&self) -> CommitVersion
pub fn version(&self) -> CommitVersion
Get the transaction version
Sourcepub fn id(&self) -> TransactionId
pub fn id(&self) -> TransactionId
Get the transaction ID
Sourcepub fn get(&mut self, key: &EncodedKey) -> Result<Option<MultiVersionValues>>
pub fn get(&mut self, key: &EncodedKey) -> Result<Option<MultiVersionValues>>
Get a value by key
Sourcepub fn contains_key(&mut self, key: &EncodedKey) -> Result<bool>
pub fn contains_key(&mut self, key: &EncodedKey) -> Result<bool>
Check if a key exists
Sourcepub fn prefix(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>
pub fn prefix(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>
Get a prefix batch
Sourcepub fn prefix_rev(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>
pub fn prefix_rev(&mut self, prefix: &EncodedKey) -> Result<MultiVersionBatch>
Get a reverse prefix batch
Sourcepub fn read_as_of_version_exclusive(
&mut self,
version: CommitVersion,
) -> Result<()>
pub fn read_as_of_version_exclusive( &mut self, version: CommitVersion, ) -> Result<()>
Read as of version exclusive
Sourcepub fn set(&mut self, key: &EncodedKey, row: EncodedValues) -> Result<()>
pub fn set(&mut self, key: &EncodedKey, row: EncodedValues) -> Result<()>
Set a key-value pair
Sourcepub fn unset(&mut self, key: &EncodedKey, values: EncodedValues) -> Result<()>
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.
Sourcepub fn remove(&mut self, key: &EncodedKey) -> Result<()>
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).
Sourcepub fn range(
&mut self,
range: EncodedKeyRange,
batch_size: usize,
) -> Result<Box<dyn Iterator<Item = Result<MultiVersionValues>> + Send + '_>>
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.
Sourcepub fn range_rev(
&mut self,
range: EncodedKeyRange,
batch_size: usize,
) -> Result<Box<dyn Iterator<Item = Result<MultiVersionValues>> + Send + '_>>
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
impl Drop for CommandTransaction
Source§impl<'a> From<&'a mut CommandTransaction> for Transaction<'a>
impl<'a> From<&'a mut CommandTransaction> for Transaction<'a>
Source§fn from(txn: &'a mut CommandTransaction) -> Self
fn from(txn: &'a mut CommandTransaction) -> Self
Source§impl WithEventBus for CommandTransaction
impl WithEventBus for CommandTransaction
Source§impl WithInterceptors for CommandTransaction
impl WithInterceptors for CommandTransaction
Source§fn table_pre_insert_interceptors(
&mut self,
) -> &mut Chain<dyn TablePreInsertInterceptor + Send + Sync>
fn table_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn TablePreInsertInterceptor + Send + Sync>
Source§fn table_post_insert_interceptors(
&mut self,
) -> &mut Chain<dyn TablePostInsertInterceptor + Send + Sync>
fn table_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn TablePostInsertInterceptor + Send + Sync>
Source§fn table_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn TablePreUpdateInterceptor + Send + Sync>
fn table_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn TablePreUpdateInterceptor + Send + Sync>
Source§fn table_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn TablePostUpdateInterceptor + Send + Sync>
fn table_post_update_interceptors( &mut self, ) -> &mut Chain<dyn TablePostUpdateInterceptor + Send + Sync>
Source§fn table_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn TablePreDeleteInterceptor + Send + Sync>
fn table_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn TablePreDeleteInterceptor + Send + Sync>
Source§fn table_post_delete_interceptors(
&mut self,
) -> &mut Chain<dyn TablePostDeleteInterceptor + Send + Sync>
fn table_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn TablePostDeleteInterceptor + Send + Sync>
Source§fn ringbuffer_pre_insert_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPreInsertInterceptor + Send + Sync>
fn ringbuffer_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreInsertInterceptor + Send + Sync>
Source§fn ringbuffer_post_insert_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPostInsertInterceptor + Send + Sync>
fn ringbuffer_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostInsertInterceptor + Send + Sync>
Source§fn ringbuffer_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPreUpdateInterceptor + Send + Sync>
fn ringbuffer_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreUpdateInterceptor + Send + Sync>
Source§fn ringbuffer_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPostUpdateInterceptor + Send + Sync>
fn ringbuffer_post_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostUpdateInterceptor + Send + Sync>
Source§fn ringbuffer_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPreDeleteInterceptor + Send + Sync>
fn ringbuffer_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPreDeleteInterceptor + Send + Sync>
Source§fn ringbuffer_post_delete_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferPostDeleteInterceptor + Send + Sync>
fn ringbuffer_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferPostDeleteInterceptor + Send + Sync>
Source§fn pre_commit_interceptors(
&mut self,
) -> &mut Chain<dyn PreCommitInterceptor + Send + Sync>
fn pre_commit_interceptors( &mut self, ) -> &mut Chain<dyn PreCommitInterceptor + Send + Sync>
Source§fn post_commit_interceptors(
&mut self,
) -> &mut Chain<dyn PostCommitInterceptor + Send + Sync>
fn post_commit_interceptors( &mut self, ) -> &mut Chain<dyn PostCommitInterceptor + Send + Sync>
Source§fn namespace_post_create_interceptors(
&mut self,
) -> &mut Chain<dyn NamespacePostCreateInterceptor + Send + Sync>
fn namespace_post_create_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePostCreateInterceptor + Send + Sync>
Source§fn namespace_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn NamespacePreUpdateInterceptor + Send + Sync>
fn namespace_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePreUpdateInterceptor + Send + Sync>
Source§fn namespace_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn NamespacePostUpdateInterceptor + Send + Sync>
fn namespace_post_update_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePostUpdateInterceptor + Send + Sync>
Source§fn namespace_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn NamespacePreDeleteInterceptor + Send + Sync>
fn namespace_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn NamespacePreDeleteInterceptor + Send + Sync>
Source§fn table_def_post_create_interceptors(
&mut self,
) -> &mut Chain<dyn TableDefPostCreateInterceptor + Send + Sync>
fn table_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPostCreateInterceptor + Send + Sync>
Source§fn table_def_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn TableDefPreUpdateInterceptor + Send + Sync>
fn table_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPreUpdateInterceptor + Send + Sync>
Source§fn table_def_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn TableDefPostUpdateInterceptor + Send + Sync>
fn table_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPostUpdateInterceptor + Send + Sync>
Source§fn table_def_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn TableDefPreDeleteInterceptor + Send + Sync>
fn table_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn TableDefPreDeleteInterceptor + Send + Sync>
Source§fn view_pre_insert_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPreInsertInterceptor + Send + Sync>
fn view_pre_insert_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreInsertInterceptor + Send + Sync>
Source§fn view_post_insert_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPostInsertInterceptor + Send + Sync>
fn view_post_insert_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostInsertInterceptor + Send + Sync>
Source§fn view_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPreUpdateInterceptor + Send + Sync>
fn view_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreUpdateInterceptor + Send + Sync>
Source§fn view_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPostUpdateInterceptor + Send + Sync>
fn view_post_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostUpdateInterceptor + Send + Sync>
Source§fn view_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPreDeleteInterceptor + Send + Sync>
fn view_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewPreDeleteInterceptor + Send + Sync>
Source§fn view_post_delete_interceptors(
&mut self,
) -> &mut Chain<dyn ViewPostDeleteInterceptor + Send + Sync>
fn view_post_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewPostDeleteInterceptor + Send + Sync>
Source§fn view_def_post_create_interceptors(
&mut self,
) -> &mut Chain<dyn ViewDefPostCreateInterceptor + Send + Sync>
fn view_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPostCreateInterceptor + Send + Sync>
Source§fn view_def_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn ViewDefPreUpdateInterceptor + Send + Sync>
fn view_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPreUpdateInterceptor + Send + Sync>
Source§fn view_def_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn ViewDefPostUpdateInterceptor + Send + Sync>
fn view_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPostUpdateInterceptor + Send + Sync>
Source§fn view_def_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn ViewDefPreDeleteInterceptor + Send + Sync>
fn view_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn ViewDefPreDeleteInterceptor + Send + Sync>
Source§fn ringbuffer_def_post_create_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferDefPostCreateInterceptor + Send + Sync>
fn ringbuffer_def_post_create_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPostCreateInterceptor + Send + Sync>
Source§fn ringbuffer_def_pre_update_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferDefPreUpdateInterceptor + Send + Sync>
fn ringbuffer_def_pre_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPreUpdateInterceptor + Send + Sync>
Source§fn ringbuffer_def_post_update_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferDefPostUpdateInterceptor + Send + Sync>
fn ringbuffer_def_post_update_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPostUpdateInterceptor + Send + Sync>
Source§fn ringbuffer_def_pre_delete_interceptors(
&mut self,
) -> &mut Chain<dyn RingBufferDefPreDeleteInterceptor + Send + Sync>
fn ringbuffer_def_pre_delete_interceptors( &mut self, ) -> &mut Chain<dyn RingBufferDefPreDeleteInterceptor + Send + Sync>
Auto Trait Implementations§
impl Freeze for CommandTransaction
impl !RefUnwindSafe for CommandTransaction
impl Send for CommandTransaction
impl Sync for CommandTransaction
impl Unpin for CommandTransaction
impl UnsafeUnpin for CommandTransaction
impl !UnwindSafe for CommandTransaction
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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