Skip to main content

Spine

Struct Spine 

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

Source

pub fn get_batches(&self) -> Vec<Arc<B>>

Source§

impl<B> Spine<B>
where B: Batch,

Source

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.

Source

pub fn complete_merges(&mut self)

Source

pub fn maybe_flush_batch<F>( batch: impl Into<Arc<B>>, factories: &B::Factories, filters: F, ) -> Arc<B>
where F: FnOnce() -> (Option<Filter<B::Key>>, Option<GroupFilter<B::Val>>),

Returns batch, first pushing it to storage if it exceeds the user-configured min_storage_bytes or if we’re under high memory pressure.

Source

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,

Source§

type Archived = ()

The archived representation of this type. Read more
Source§

type Resolver = ()

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

unsafe fn resolve( &self, _pos: usize, _resolver: Self::Resolver, _out: *mut Self::Archived, )

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

impl<B> BatchReader for Spine<B>
where B: Batch,

Source§

type Key = <B as BatchReader>::Key

Key by which updates are indexed.
Source§

type Val = <B as BatchReader>::Val

Values associated with keys.
Source§

type Time = <B as BatchReader>::Time

Timestamps associated with updates
Source§

type R = <B as BatchReader>::R

Associated update.
Source§

type Factories = <B as BatchReader>::Factories

Source§

type Cursor<'s> = SpineCursor<B>

The type used to enumerate the batch’s contents.
Source§

fn factories(&self) -> Self::Factories

Source§

fn key_count(&self) -> usize

The number of keys in the batch.
Source§

fn len(&self) -> usize

The number of updates in the batch.
Source§

fn approximate_byte_size(&self) -> usize

The memory or storage size of the batch in bytes. Read more
Source§

fn range_filter_stats(&self) -> FilterStats

Statistics of the in-memory range filter used by Cursor::seek_key_exact. Read more
Source§

fn cursor(&self) -> Self::Cursor<'_>

Acquires a cursor to the batch’s contents.
Source§

fn sample_keys<RG>( &self, rng: &mut RG, sample_size: usize, sample: &mut DynVec<Self::Key>, )
where RG: Rng,

Returns a uniform random sample of distincts keys from the batch. Read more
Source§

async fn fetch<KR>( &self, keys: &KR, ) -> Option<Box<dyn CursorFactory<Self::Key, Self::Val, Self::Time, Self::R>>>
where KR: BatchReader<Key = Self::Key, Time = ()>,

Creates and returns a new batch that is a subset of this one, containing only the key-value pairs whose keys are in 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 more
Source§

fn push_cursor( &self, ) -> Box<dyn PushCursor<Self::Key, Self::Val, Self::Time, Self::R> + Send + '_>

Acquires a PushCursor for the batch’s contents.
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 + '_>

Acquires a MergeCursor for the batch’s contents.
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>
where S: BatchReader<Key = Self::Key, Val = Self::Val, Time = Self::Time, R = Self::R>,

Similar to 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 + '_>

Acquires a merge cursor for the batch’s contents.
Source§

fn membership_filter_stats(&self) -> FilterStats

Statistics of the secondary membership filter used by Cursor::seek_key_exact after the range filter. Read more
Source§

fn membership_filter_kind(&self) -> FilterKind

Filter kind for the secondary membership filter used by Cursor::seek_key_exact.
Source§

fn location(&self) -> BatchLocation

Where the batch’s data is stored.
Source§

fn cache_stats(&self) -> CacheStats

Storage cache access statistics for this batch only. Read more
Source§

fn is_empty(&self) -> bool

True if the batch is empty.
Source§

fn partition_keys(&self, num_partitions: usize, bounds: &mut DynVec<Self::Key>)
where Self::Time: PartialEq<()>,

Returns num_partitions-1 keys from the batch that partition the batch into num_partitions approximately equal size ranges 0..key1, key1..key2, … , key_num_partitions-1..last_key_in_the_batch. Read more
Source§

fn keys(&self) -> Option<&DynVec<Self::Key>>

Source§

impl<B> Clone for Spine<B>
where B: Batch,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B> Debug for Spine<B>
where B: Batch,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<B: Batch, D: Fallible> Deserialize<Spine<B>, D> for Archived<Spine<B>>

Source§

fn deserialize(&self, _deserializer: &mut D) -> Result<Spine<B>, D::Error>

Deserializes using the given deserializer
Source§

impl<B> Display for Spine<B>
where B: Batch + Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B> From<&Spine<B>> for SpineSnapshot<B>
where B: Batch + Send + Sync,

Source§

fn from(spine: &Spine<B>) -> Self

Converts to this type from the input type.
Source§

impl<B> NumEntries for Spine<B>
where B: Batch,

Source§

const CONST_NUM_ENTRIES: Option<usize> = None

Returns Some(n) if Self has constant size or None otherwise.
Source§

fn num_entries_shallow(&self) -> usize

Returns the number of entries in self.
Source§

fn num_entries_deep(&self) -> usize

Recursively computes the number of entries in a container by calling this method on each entry in self. Read more
Source§

impl<B: Batch, S: Serializer + ?Sized> Serialize<S> for Spine<B>

Source§

fn serialize(&self, _serializer: &mut S) -> Result<Self::Resolver, S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<B> SizeOf for Spine<B>
where B: Batch,

Source§

fn size_of_children(&self, context: &mut Context)

Gets the size of all “children” owned by this value, not including the size of the value itself. Read more
Source§

fn size_of(&self) -> TotalSize

Gets the total size of the current value
Source§

fn size_of_with_context(&self, context: &mut Context)

Adds the size of the current value to the given Context, including both the size of the value itself and all of its children
Source§

impl<B> Trace for Spine<B>
where B: Batch,

Source§

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)

Waits for the number of batches in the spine to fall below the level at which we impose backpressure.

Source§

type Batch = B

The type of an immutable collection of updates.
Source§

fn new(factories: &B::Factories, name: Arc<String>) -> Self

Allocates a new empty trace associated with name, which should identify the operator or other origin of the trace.
Source§

fn set_name(&mut self, name: Arc<String>)

Updates the name of the trace to name.
Source§

fn set_frontier(&mut self, frontier: &B::Time)

Sets a compaction frontier, i.e., a timestamp such that timestamps below the frontier are indistinguishable to DBSP, therefore any 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 more
Source§

fn exert(&mut self, _effort: &mut isize)

Exert merge effort, even without updates.
Source§

fn consolidate(self) -> Option<B>

Merge all updates in a trace into a single batch.
Source§

async fn insert(&mut self, batch: impl Into<Arc<Self::Batch>>)

Introduces a batch of updates to the trace. Read more
Source§

fn clear_dirty_flag(&mut self)

Clears the value of the “dirty” flag to false. Read more
Source§

fn dirty(&self) -> bool

Returns the value of the dirty flag.
Source§

fn retain_keys(&mut self, filter: Filter<Self::Key>)

Informs the trace that keys that don’t pass the filter are no longer used and can be removed from the trace. Read more
Source§

fn retain_values(&mut self, filter: GroupFilter<Self::Val>)

Informs the trace that values that don’t pass the filter are no longer used and can be removed from the trace. Read more
Source§

fn key_filter(&self) -> &Option<Filter<Self::Key>>

Source§

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>

Writes this trace to storage beneath 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>

Reads this trace back from storage under base with pid as the prefix.
Source§

fn metadata(&self, meta: &mut OperatorMeta)

Allows the trace to report additional metadata.
Source§

fn initiate_compaction(&self)

Source§

fn is_compaction_complete(&self) -> bool

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

Source§

type Batch = B

Source§

fn ro_snapshot(&self) -> SpineSnapshot<B>

Returns a read-only, non-merging snapshot of the current trace state.
Source§

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>
where <B as BatchReader>::Factories: Freeze,

§

impl<B> Send for Spine<B>

§

impl<B> Sync for Spine<B>

§

impl<B> Unpin for Spine<B>
where <B as BatchReader>::Factories: Unpin,

§

impl<B> UnsafeUnpin for Spine<B>

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

type MetadataResolver = ()

The resolver for the metadata of this type. Read more
Source§

unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )

Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
Source§

unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived>, )

Resolves a relative pointer to this value with the given from and to and writes it to the given output. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<B> BatchReaderWithSnapshot for B
where 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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomError for T
where T: Display + Debug + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Send + Sync + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync + 'static)

Source§

fn as_box_any(self: Box<T>) -> Box<dyn Any + Send + Sync>

Source§

impl<T> Data for T
where T: Clone + 'static,

Source§

impl<T> DeserializableDyn for T
where T: ArchivedDBData,

Source§

unsafe fn deserialize_from_bytes_with( &mut self, bytes: &[u8], pos: usize, deserializer: &mut Deserializer, )

Deserialize self from the given slice and offset. Read more
Source§

unsafe fn deserialize_from_bytes(&mut self, bytes: &[u8], pos: usize)

Deserialize self from the given slice and offset using the default deserializer configuration. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Z> IndexedZSetReader for Z
where Z: BatchReader<Time = (), R = dyn WeightTyped<Type = i64>>,

Source§

fn iter(&self) -> IndexedZSetIterator<'_, Self>

Returns an iterator over updates in the indexed Z-set.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<K, V, B> PartitionedBatchReader<K, V> for B
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, B: BatchReader<Val = dyn Pair<K, V>, Time = ()>,

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

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Rkyv for T
where T: Archive + for<'a> Serialize<DbspSerializer<'a>> + Deserializable,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SerializeDyn for T
where T: ArchivedDBData,

Source§

fn serialize( &self, serializer: &mut DbspSerializer<'_>, ) -> Result<usize, <DbspSerializer<'_> as Fallible>::Error>

Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Serializer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<B> ZBatchReader for B
where B: BatchReader<R = dyn WeightTyped<Type = i64>>,

Source§

impl<Z> ZSetReader for Z
where Z: IndexedZSetReader<Val = dyn DataTyped<Type = ()>>,

Source§

impl<T> ZTrace for T
where T: Trace<R = dyn WeightTyped<Type = i64>>,