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_effort(factories: &B::Factories, _effort: usize) -> Self

Allocates a fueled Spine with a specified effort multiplier.

This trace will merge batches progressively, with each inserted batch applying a multiple of the batch’s length in effort to each merge. The effort parameter is that multiplier. This value should be at least one for the merging to happen; a value of zero is not helpful.

Source

pub fn complete_merges(&mut self)

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 filter_stats(&self) -> BloomFilterStats

Statistics of the Bloom filter used by Cursor::seek_key_exact. The Bloom filter (kept in memory) is used there to quickly check whether a key might be present in the batch, before doing a binary tree lookup within the batch to be exactly sure. The statistics include for example the size in bytes and the hit rate. Only some kinds of batches use a filter; others should return BloomFilterStats::default().
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 Self::Time: PartialEq<()>, 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 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 maybe_contains_key(&self, _hash: u64) -> bool

A method that returns either true (possibly in the batch) or false (definitely not in the batch).
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 · 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§

type Batch = B

The type of an immutable collection of updates.
Source§

fn new(factories: &B::Factories) -> Self

Allocates a new empty trace.
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§

fn insert(&mut self, batch: Self::Batch)

Introduces a batch of updates to the trace.
Source§

fn insert_arc(&mut self, batch: Arc<Self::Batch>)

Introduces a batch of updates to the trace. More efficient that cloning a batch and calling insert.
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§

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

§

impl<B> !RefUnwindSafe for Spine<B>

§

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>

§

impl<B> !UnwindSafe 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<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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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<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: 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: 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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> 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> Data for T
where T: Clone + 'static,

Source§

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

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

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