pub struct EngineTransaction<T: LinkReference, L: TransitionLogStore> { /* private fields */ }Expand description
An isolated write set with the same raw LinksStorage API as other backends. Dropping or rolling back discards the write set; allocation may leave gaps.
Implementations§
Source§impl<T: LinkReference, L: TransitionLogStore> EngineTransaction<T, L>
impl<T: LinkReference, L: TransitionLogStore> EngineTransaction<T, L>
Sourcepub fn savepoint(&mut self) -> Result<Savepoint, LinkError>
pub fn savepoint(&mut self) -> Result<Savepoint, LinkError>
Remember the current write set. Savepoints nest.
Source§impl<T: LinkReference, L: TransitionLogStore> EngineTransaction<T, L>
impl<T: LinkReference, L: TransitionLogStore> EngineTransaction<T, L>
Sourcepub fn lock_for_update(
&mut self,
id: T,
) -> Result<Option<GenericLink<T>>, LinkError>
pub fn lock_for_update( &mut self, id: T, ) -> Result<Option<GenericLink<T>>, LinkError>
Reads a link and reserves its address for this session, like SQL
SELECT ... FOR UPDATE. Another session’s write or lock of the address
is then refused (or waits, with lock_wait) until this session ends, so
a read-modify-write cannot be overtaken. A missing address is reserved
too, which keeps other sessions from creating it. Refused with busy
while another session owns the address, and with conflict when the
link changed after this session began. Needs pessimistic concurrency.
Sourcepub fn write_owner(&self) -> Option<u64>
pub fn write_owner(&self) -> Option<u64>
Identifies this session’s write ownership while it lasts. None unless
the engine selected pessimistic concurrency.
Sourcepub fn take_write_blocker(&mut self) -> Option<u64>
pub fn take_write_blocker(&mut self) -> Option<u64>
The owner that refused this session’s last write, once. Lets a caller that cannot block, such as JavaScript on one thread, wait and detect cycles itself.
pub fn get_name(&self, id: T) -> Option<String>
pub fn set_name(&mut self, id: T, name: Option<String>) -> Result<(), LinkError>
pub fn get_by_name(&self, name: &str) -> Option<T>
pub fn rollback(&mut self)
pub fn commit(&mut self) -> Result<u64, LinkError>
Trait Implementations§
Source§impl<T: LinkReference, L: TransitionLogStore> Drop for EngineTransaction<T, L>
impl<T: LinkReference, L: TransitionLogStore> Drop for EngineTransaction<T, L>
Source§impl<T: LinkReference, L: TransitionLogStore> LinksStorage<T> for EngineTransaction<T, L>
impl<T: LinkReference, L: TransitionLogStore> LinksStorage<T> for EngineTransaction<T, L>
Source§fn flush(&mut self) -> Result<(), LinkError>
fn flush(&mut self) -> Result<(), LinkError>
Flush commits the staged transaction, rather than exposing uncommitted data.
Source§fn create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
fn create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
Source§fn ensure_link_created(&mut self, id: T) -> Result<T, LinkError>
fn ensure_link_created(&mut self, id: T) -> Result<T, LinkError>
index, creating placeholders as needed.Source§fn get_link(&self, id: T) -> Option<GenericLink<T>>
fn get_link(&self, id: T) -> Option<GenericLink<T>>
index, if any.Source§fn update_link(
&mut self,
id: T,
source: T,
target: T,
) -> Result<GenericLink<T>, LinkError>
fn update_link( &mut self, id: T, source: T, target: T, ) -> Result<GenericLink<T>, LinkError>
index at source/target, returning the previous state.Source§fn delete_link(&mut self, id: T) -> Result<GenericLink<T>, LinkError>
fn delete_link(&mut self, id: T) -> Result<GenericLink<T>, LinkError>
index, returning the link that was removed.Source§fn all_links(&self) -> Vec<GenericLink<T>>
fn all_links(&self) -> Vec<GenericLink<T>>
Source§fn create_link_observed(
&mut self,
source: T,
target: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<T, LinkError>
fn create_link_observed( &mut self, source: T, target: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<T, LinkError>
Self::create_link, reporting every change, including partial changes
before an error. Transactions need these callbacks to distinguish a new
allocation from a duplicate resolved into an existing link. Read moreSource§fn ensure_link_created_observed(
&mut self,
index: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<T, LinkError>
fn ensure_link_created_observed( &mut self, index: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<T, LinkError>
Self::ensure_link_created, reporting every placeholder it creates. Read moreSource§fn link_exists(&self, index: T) -> bool
fn link_exists(&self, index: T) -> bool
true when a link exists at index.Source§fn restore_link(
&mut self,
index: T,
source: T,
target: T,
) -> Result<GenericLink<T>, LinkError>
fn restore_link( &mut self, index: T, source: T, target: T, ) -> Result<GenericLink<T>, LinkError>
Source§fn update_link_observed(
&mut self,
index: T,
source: T,
target: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<GenericLink<T>, LinkError>
fn update_link_observed( &mut self, index: T, source: T, target: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<GenericLink<T>, LinkError>
Source§fn delete_link_observed(
&mut self,
index: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<GenericLink<T>, LinkError>
fn delete_link_observed( &mut self, index: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<GenericLink<T>, LinkError>
Source§fn query_links(
&self,
index: Option<T>,
source: Option<T>,
target: Option<T>,
) -> Vec<GenericLink<T>>
fn query_links( &self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<GenericLink<T>>
Source§fn search_link(&self, source: T, target: T) -> Option<T>
fn search_link(&self, source: T, target: T) -> Option<T>
Source§fn get_or_create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
fn get_or_create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
(source, target) link,
creating it when it does not exist yet.Source§fn links_count(&self) -> usize
fn links_count(&self) -> usize
Source§fn capture_names(&mut self) -> Result<Option<BTreeMap<T, String>>, LinkError>
fn capture_names(&mut self) -> Result<Option<BTreeMap<T, String>>, LinkError>
Source§fn set_link_name(
&mut self,
_index: T,
_name: Option<&str>,
) -> Result<T, LinkError>
fn set_link_name( &mut self, _index: T, _name: Option<&str>, ) -> Result<T, LinkError>
Source§impl<T: QueryAddress, L: TransitionLogStore> NamedTypeLinks<T> for EngineTransaction<T, L>
impl<T: QueryAddress, L: TransitionLogStore> NamedTypeLinks<T> for EngineTransaction<T, L>
Source§fn reserve_query_allocations(
&mut self,
processor: &GenericQueryProcessor<T>,
restriction: &LinoLink,
substitution: &LinoLink,
) -> Result<Option<HashSet<T>>>
fn reserve_query_allocations( &mut self, processor: &GenericQueryProcessor<T>, restriction: &LinoLink, substitution: &LinoLink, ) -> Result<Option<HashSet<T>>>
fn create(&mut self, source: T, target: T) -> T
Source§fn try_create(&mut self, source: T, target: T) -> Result<T>
fn try_create(&mut self, source: T, target: T) -> Result<T>
fn ensure_created(&mut self, id: T) -> T
fn try_ensure_created(&mut self, id: T) -> Result<T>
fn get_link(&mut self, id: T) -> Option<Link<T>>
fn exists(&mut self, id: T) -> bool
Source§fn update_observed(
&mut self,
id: T,
source: T,
target: T,
observer: ChangeObserver<'_, T>,
) -> Result<Link<T>>
fn update_observed( &mut self, id: T, source: T, target: T, observer: ChangeObserver<'_, T>, ) -> Result<Link<T>>
Self::update, reporting every change the update caused. Read moreSource§fn delete_observed(
&mut self,
id: T,
observer: ChangeObserver<'_, T>,
) -> Result<Link<T>>
fn delete_observed( &mut self, id: T, observer: ChangeObserver<'_, T>, ) -> Result<Link<T>>
Self::delete, reporting every change the deletion caused. Read morefn all_links(&mut self) -> Vec<Link<T>>
fn search(&mut self, source: T, target: T) -> Option<T>
fn get_or_create(&mut self, source: T, target: T) -> T
fn get_name(&mut self, id: T) -> Result<Option<String>>
fn set_name(&mut self, id: T, name: &str) -> Result<T>
fn get_by_name(&mut self, name: &str) -> Result<Option<T>>
fn remove_name(&mut self, id: T) -> Result<()>
fn save(&mut self) -> Result<()>
Source§fn query_limits(&self) -> Option<QueryLimits>
fn query_limits(&self) -> Option<QueryLimits>
Source§fn reference_exists(&mut self, id: T) -> bool
fn reference_exists(&mut self, id: T) -> bool
id names a link that exists. Read moreSource§fn claims(&mut self, id: T) -> Option<bool>
fn claims(&mut self, id: T) -> Option<bool>
id is an address of this store, so a link created there
(Self::ensure_created, the undo of a delete) belongs in it; None
for a plain store, which has no addresses of its own. Read moreSource§fn next_created_addresses(&mut self, count: usize) -> Result<Vec<T>>
fn next_created_addresses(&mut self, count: usize) -> Result<Vec<T>>
count links created in the store get. Read morefn update(&mut self, id: T, source: T, target: T) -> Result<GenericLink<T>>
fn delete(&mut self, id: T) -> Result<GenericLink<T>>
Source§fn query_links(
&mut self,
index: Option<T>,
source: Option<T>,
target: Option<T>,
) -> Vec<GenericLink<T>>
fn query_links( &mut self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<GenericLink<T>>
None matches any value, in
the order of their addresses. Read more