pub struct Spine<B>where
B: Batch,{ /* private fields */ }Expand description
Persistence optimized trace implementation based on collection and merging immutable batches of updates.
This spine works asynchronously. The batches exposed to cursors are maintained separately from the batches currently being merged by an asynchronous thread. When one or more merges complete, the spine fetches the new (smaller) collection of batches from the thread in the next step. (It could fetch them earlier, but it might be unfriendly to expose potentially one form of data to a given cursor and then a different form to the next one within a single step.)
Implementations§
Source§impl<B> Spine<B>where
B: Batch,
impl<B> Spine<B>where
B: Batch,
Sourcepub fn with_runtime(
runtime: Runtime,
worker_index: usize,
factories: &B::Factories,
name: Arc<String>,
) -> Self
pub fn with_runtime( runtime: Runtime, worker_index: usize, factories: &B::Factories, name: Arc<String>, ) -> Self
Allocates a new Spine for worker_index in runtime.
In the common case, Spine::new uses the current thread’s runtime and worker index.
pub fn complete_merges(&mut self)
Sourcepub fn maybe_flush_batch<F>(
batch: impl Into<Arc<B>>,
factories: &B::Factories,
filters: F,
) -> Arc<B> ⓘ
pub fn maybe_flush_batch<F>( batch: impl Into<Arc<B>>, factories: &B::Factories, filters: F, ) -> Arc<B> ⓘ
Returns batch, first pushing it to storage if it exceeds the
user-configured min_storage_bytes or if we’re under high memory
pressure.
Sourcepub fn backpressure_waiter(&self) -> Option<OwnedNotified>
pub fn backpressure_waiter(&self) -> Option<OwnedNotified>
Returns an object that can be used to wait for backpressure to be
relieved. Returns None if no backpressure is needed.
Trait Implementations§
Source§impl<B> Archive for Spine<B>where
B: Batch,
impl<B> Archive for Spine<B>where
B: Batch,
Source§impl<B> BatchReader for Spine<B>where
B: Batch,
impl<B> BatchReader for Spine<B>where
B: Batch,
Source§type Key = <B as BatchReader>::Key
type Key = <B as BatchReader>::Key
Source§type Val = <B as BatchReader>::Val
type Val = <B as BatchReader>::Val
Source§type Time = <B as BatchReader>::Time
type Time = <B as BatchReader>::Time
Source§type R = <B as BatchReader>::R
type R = <B as BatchReader>::R
type Factories = <B as BatchReader>::Factories
Source§type Cursor<'s> = SpineCursor<B>
type Cursor<'s> = SpineCursor<B>
fn factories(&self) -> Self::Factories
Source§fn approximate_byte_size(&self) -> usize
fn approximate_byte_size(&self) -> usize
Source§fn range_filter_stats(&self) -> FilterStats
fn range_filter_stats(&self) -> FilterStats
Source§fn sample_keys<RG>(
&self,
rng: &mut RG,
sample_size: usize,
sample: &mut DynVec<Self::Key>,
)where
RG: Rng,
fn sample_keys<RG>(
&self,
rng: &mut RG,
sample_size: usize,
sample: &mut DynVec<Self::Key>,
)where
RG: Rng,
Source§async fn fetch<KR>(
&self,
keys: &KR,
) -> Option<Box<dyn CursorFactory<Self::Key, Self::Val, Self::Time, Self::R>>>
async fn fetch<KR>( &self, keys: &KR, ) -> Option<Box<dyn CursorFactory<Self::Key, Self::Val, Self::Time, Self::R>>>
keys. May also return
None, the default implementation, if the batch doesn’t want to
implement this method. In particular, a batch for which access through
a cursor is fast should return None to avoid the expense of copying
data. Read moreSource§fn push_cursor(
&self,
) -> Box<dyn PushCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
fn push_cursor( &self, ) -> Box<dyn PushCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
Source§fn merge_cursor(
&self,
key_filter: Option<Filter<Self::Key>>,
value_filter: Option<GroupFilter<Self::Val>>,
) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
fn merge_cursor( &self, key_filter: Option<Filter<Self::Key>>, value_filter: Option<GroupFilter<Self::Val>>, ) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
Source§fn merge_cursor_with_snapshot<'a, S>(
&'a self,
key_filter: Option<Filter<Self::Key>>,
value_filter: Option<GroupFilter<Self::Val>>,
snapshot: &'a Option<Arc<S>>,
) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + 'a>
fn merge_cursor_with_snapshot<'a, S>( &'a self, key_filter: Option<Filter<Self::Key>>, value_filter: Option<GroupFilter<Self::Val>>, snapshot: &'a Option<Arc<S>>, ) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + 'a>
merge_cursor, but invoked in the context of a spine merger.
Takes the current spine snapshot as an extra argument and uses it to evaluate value_filter precisely.Source§fn consuming_cursor(
&mut self,
key_filter: Option<Filter<Self::Key>>,
value_filter: Option<GroupFilter<Self::Val>>,
) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
fn consuming_cursor( &mut self, key_filter: Option<Filter<Self::Key>>, value_filter: Option<GroupFilter<Self::Val>>, ) -> Box<dyn MergeCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>
Source§fn membership_filter_stats(&self) -> FilterStats
fn membership_filter_stats(&self) -> FilterStats
Source§fn membership_filter_kind(&self) -> FilterKind
fn membership_filter_kind(&self) -> FilterKind
Source§fn location(&self) -> BatchLocation
fn location(&self) -> BatchLocation
Source§fn cache_stats(&self) -> CacheStats
fn cache_stats(&self) -> CacheStats
Source§fn partition_keys(&self, num_partitions: usize, bounds: &mut DynVec<Self::Key>)
fn partition_keys(&self, num_partitions: usize, bounds: &mut DynVec<Self::Key>)
fn keys(&self) -> Option<&DynVec<Self::Key>>
Source§impl<B> From<&Spine<B>> for SpineSnapshot<B>
impl<B> From<&Spine<B>> for SpineSnapshot<B>
Source§impl<B> NumEntries for Spine<B>where
B: Batch,
impl<B> NumEntries for Spine<B>where
B: Batch,
Source§const CONST_NUM_ENTRIES: Option<usize> = None
const CONST_NUM_ENTRIES: Option<usize> = None
Some(n) if Self has constant size or None otherwise.Source§fn num_entries_shallow(&self) -> usize
fn num_entries_shallow(&self) -> usize
self.Source§fn num_entries_deep(&self) -> usize
fn num_entries_deep(&self) -> usize
self. Read moreSource§impl<B> SizeOf for Spine<B>where
B: Batch,
impl<B> SizeOf for Spine<B>where
B: Batch,
Source§fn size_of_children(&self, context: &mut Context)
fn size_of_children(&self, context: &mut Context)
Source§fn size_of_with_context(&self, context: &mut Context)
fn size_of_with_context(&self, context: &mut Context)
Context,
including both the size of the value itself and all of its childrenSource§impl<B> Trace for Spine<B>where
B: Batch,
impl<B> Trace for Spine<B>where
B: Batch,
Source§fn insert_without_blocking(&mut self, batch: impl Into<Arc<B>>) -> bool
fn insert_without_blocking(&mut self, batch: impl Into<Arc<B>>) -> bool
Inserts a batch into the spine without blocking. Thus, this omits:
-
Spilling the batch to storage when that is a good idea. The caller may do this beforehand by calling Spine::maybe_flush_batch.
-
Waiting until the number of batches in the spine falls below the level at which we impose backpressure. The function returns true if backpressure is warranted. The caller may do so afterward by calling Spine::backpressure_wait.
Source§async fn backpressure_wait(&self)
async fn backpressure_wait(&self)
Waits for the number of batches in the spine to fall below the level at which we impose backpressure.
Source§fn new(factories: &B::Factories, name: Arc<String>) -> Self
fn new(factories: &B::Factories, name: Arc<String>) -> Self
name, which should
identify the operator or other origin of the trace.Source§fn set_frontier(&mut self, frontier: &B::Time)
fn set_frontier(&mut self, frontier: &B::Time)
ts
in the trace can be safely replaced with ts.join(frontier) without
affecting the output of the circuit. By applying this replacement,
updates to the same (key, value) pairs applied during different steps
can be merged or discarded. Read moreSource§fn consolidate(self) -> Option<B>
fn consolidate(self) -> Option<B>
Source§async fn insert(&mut self, batch: impl Into<Arc<Self::Batch>>)
async fn insert(&mut self, batch: impl Into<Arc<Self::Batch>>)
Source§fn clear_dirty_flag(&mut self)
fn clear_dirty_flag(&mut self)
false. Read moreSource§fn retain_keys(&mut self, filter: Filter<Self::Key>)
fn retain_keys(&mut self, filter: Filter<Self::Key>)
Source§fn retain_values(&mut self, filter: GroupFilter<Self::Val>)
fn retain_values(&mut self, filter: GroupFilter<Self::Val>)
fn key_filter(&self) -> &Option<Filter<Self::Key>>
fn value_filter(&self) -> &Option<GroupFilter<Self::Val>>
Source§fn save(
&mut self,
base: &StoragePath,
persistent_id: &str,
files: &mut Vec<Arc<dyn FileCommitter>>,
) -> Result<(), Error>
fn save( &mut self, base: &StoragePath, persistent_id: &str, files: &mut Vec<Arc<dyn FileCommitter>>, ) -> Result<(), Error>
base, using pid as a file name
prefix. Adds the files that were written to files so that they can be
committed later.Source§fn restore(
&mut self,
base: &StoragePath,
persistent_id: &str,
) -> Result<(), Error>
fn restore( &mut self, base: &StoragePath, persistent_id: &str, ) -> Result<(), Error>
base with pid as the
prefix.Source§fn metadata(&self, meta: &mut OperatorMeta)
fn metadata(&self, meta: &mut OperatorMeta)
fn initiate_compaction(&self)
Source§fn is_compaction_complete(&self) -> bool
fn is_compaction_complete(&self) -> bool
true when compaction has fully converged: all compaction
requests have been processed, no background merge is in progress, and
the trace has been reduced to at most one batch.Source§impl<B> WithSnapshot for Spine<B>where
B: Batch,
impl<B> WithSnapshot for Spine<B>where
B: Batch,
type Batch = B
Source§fn ro_snapshot(&self) -> SpineSnapshot<B>
fn ro_snapshot(&self) -> SpineSnapshot<B>
fn into_ro_snapshot(self) -> SpineSnapshot<Self::Batch>
Auto Trait Implementations§
impl<B> !RefUnwindSafe for Spine<B>
impl<B> !UnwindSafe for Spine<B>
impl<B> Freeze for Spine<B>
impl<B> Send for Spine<B>
impl<B> Sync for Spine<B>
impl<B> Unpin for Spine<B>
impl<B> UnsafeUnpin for Spine<B>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be unsized. Read moreSource§type MetadataResolver = ()
type MetadataResolver = ()
Source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
impl<B> BatchReaderWithSnapshot for Bwhere
B: BatchReader<Key = <<B as WithSnapshot>::Batch as BatchReader>::Key, Val = <<B as WithSnapshot>::Batch as BatchReader>::Val, Time = <<B as WithSnapshot>::Batch as BatchReader>::Time, R = <<B as WithSnapshot>::Batch as BatchReader>::R> + WithSnapshot,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomError for T
impl<T> CustomError for T
impl<T> Data for Twhere
T: Clone + 'static,
Source§impl<T> DeserializableDyn for Twhere
T: ArchivedDBData,
impl<T> DeserializableDyn for Twhere
T: ArchivedDBData,
Source§unsafe fn deserialize_from_bytes_with(
&mut self,
bytes: &[u8],
pos: usize,
deserializer: &mut Deserializer,
)
unsafe fn deserialize_from_bytes_with( &mut self, bytes: &[u8], pos: usize, deserializer: &mut Deserializer, )
self from the given slice and offset. Read moreSource§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<Z> IndexedZSetReader for Z
impl<Z> IndexedZSetReader for Z
Source§fn iter(&self) -> IndexedZSetIterator<'_, Self> ⓘ
fn iter(&self) -> IndexedZSetIterator<'_, Self> ⓘ
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