Skip to main content

PreparedRelationDeltaCommit

Struct PreparedRelationDeltaCommit 

Source
pub struct PreparedRelationDeltaCommit<'a> { /* private fields */ }
Expand description

A fully staged relation update bound to its authoritative and derived state.

The exclusive borrows prevent callers from mutating or substituting the authoritative store, cache, or runtime between preparation and commit. Dropping this value discards every staged update and prospective derived state. The authoritative store remains unchanged, while the borrowed cache and runtime slots remain empty because their prior values were consumed by preparation.

A prepared commit has no API for selecting a different destination:

use xlog_gpu::logic::PreparedRelationDeltaCommit;
use xlog_runtime::RelationStore;

fn commit_into_another_store(
    prepared: PreparedRelationDeltaCommit<'_>,
    other: &mut RelationStore,
) {
    prepared.commit(other);
}

The source store also remains exclusively borrowed until commit:

use std::sync::Arc;
use xlog_core::Result;
use xlog_cuda::{CudaBuffer, CudaKernelProvider};
use xlog_gpu::logic::{
    LogicMaterializedStore, LogicProgram, LogicSessionRuntime, PreparedRelationDeltaBatch,
};
use xlog_runtime::RelationStore;

fn mutate_after_prepare(
    program: &LogicProgram,
    provider: Arc<CudaKernelProvider>,
    store: &mut RelationStore,
    cache: &mut Option<LogicMaterializedStore>,
    runtime: &mut Option<LogicSessionRuntime>,
    batch: PreparedRelationDeltaBatch,
    replacement: CudaBuffer,
) -> Result<()> {
    let prepared = program.prepare_relation_delta_commit_with_session_runtime(
        provider, store, cache, runtime, batch,
    )?;
    store.put("fact", replacement);
    prepared.commit();
    Ok(())
}

Implementations§

Source§

impl PreparedRelationDeltaCommit<'_>

Source

pub fn prospective_derived_store(&self) -> &RelationStore

Borrow the prospective materialized derived/cache store.

This store is suitable for direct query-result comparison. It must not seed an independent full recompute because it contains intensional heads that an executor may union with newly derived rows. For a no-op batch it returns retained derived state when available, or the unchanged authoritative store otherwise.

Source

pub fn clone_prospective_base_store(&self) -> Result<RelationStore>

Clone the authoritative base snapshot with every staged base update overlaid.

This fallible, on-demand snapshot is the correct seed for an independent full recompute. It includes staged relations that were absent from the authoritative store and does not mutate authoritative contents or versions. Ordinary prepare and commit paths do not pay for these clones.

Source

pub fn commit(self) -> LogicDeltaReport

Install every staged base update and derived-state replacement together.

All allocation, destination-capacity reservation, recomputation, constraint validation, and buffer cloning has completed before this method is available, so committing only moves owned values and is infallible.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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, 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, 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.