Trait mz_stash::Stash

source ·
pub trait Stash: Debug + Send {
Show 21 methods fn collection<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<StashCollection<K, V>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
; fn collections<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<BTreeSet<String>, StashError>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn iter<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<((K, V), Timestamp, Diff)>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
; fn iter_key<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>,
        key: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(V, Timestamp, Diff)>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
; fn update_many<'life0, 'async_trait, K, V, I>(
        &'life0 mut self,
        collection: StashCollection<K, V>,
        entries: I
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        I: IntoIterator<Item = ((K, V), Timestamp, Diff)> + Send + 'async_trait,
        I::IntoIter: Send,
        Self: 'async_trait,
        'life0: 'async_trait
; fn seal<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>,
        upper: AntichainRef<'life1, Timestamp>
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
; fn compact<'a, 'async_trait, K, V>(
        &'a mut self,
        collection: StashCollection<K, V>,
        since: AntichainRef<'a, Timestamp>
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'a: 'async_trait
; fn consolidate<'life0, 'async_trait>(
        &'life0 mut self,
        collection: Id
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn since<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<Antichain<Timestamp>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
; fn upper<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<Antichain<Timestamp>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
; fn confirm_leadership<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn epoch(&self) -> Option<NonZeroI64>; fn is_readonly(&self) -> bool; fn peek_timestamp<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<Timestamp, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } fn peek<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(K, V, Diff)>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } fn peek_one<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>
    ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<K, V>, StashError>> + Send + 'async_trait>>
    where
        K: Data + Hash + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } fn peek_key_one<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>,
        key: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>, StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn update<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        collection: StashCollection<K, V>,
        data: (K, V),
        time: Timestamp,
        diff: Diff
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } fn seal_batch<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        seals: &'life1 [(StashCollection<K, V>, Antichain<Timestamp>)]
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn compact_batch<'life0, 'life1, 'async_trait, K, V>(
        &'life0 mut self,
        compactions: &'life1 [(StashCollection<K, V>, Antichain<Timestamp>)]
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        K: Data + 'async_trait,
        V: Data + 'async_trait,
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn consolidate_batch<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        collections: &'life1 [Id]
    ) -> Pin<Box<dyn Future<Output = Result<(), StashError>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... }
}
Expand description

A durable metadata store.

A stash manages any number of named StashCollections.

A stash is designed to store only a small quantity of data. Think megabytes, not gigabytes.

The API of a stash intentionally mimics the API of a STORAGE collection. You can think of stash as a stable but very low performance STORAGE collection. When the STORAGE layer is stable enough to serve as a source of truth, the intent is to swap all stashes for STORAGE collections.

Required Methods§

Loads or creates the named collection.

If the collection with the specified name does not yet exist, it is created with no entries, a zero since frontier, and a zero upper frontier. Otherwise the existing durable state is loaded.

It is the callers responsibility to keep K and V fixed for a given collection in a given stash for the lifetime of the stash.

It is valid to construct multiple handles to the same named collection and use them simultaneously.

Returns the names of the collections in the stash.

Iterates over all entries in the stash.

Entries are iterated in (key, value, time) order and are guaranteed to be consolidated.

Each entry’s time is guaranteed to be greater than or equal to the since frontier. The time may also be greater than the upper frontier, indicating data that has not yet been made definite.

Iterates over entries in the stash for the given key.

Entries are iterated in (value, timestamp) order and are guaranteed to be consolidated.

Each entry’s time is guaranteed to be greater than or equal to the since frontier. The time may also be greater than the upper frontier, indicating data that has not yet been made definite.

Atomically adds multiple entries to the arrangement.

Each entry’s time must be greater than or equal to the upper frontier.

If this method returns Ok, the entries have been made durable.

Atomically advances the upper frontier to the specified value.

The provided upper must be greater than or equal to the current upper frontier.

Intuitively, this method declares that all times less than upper are definite.

Atomically advances the since frontier to the specified value.

The provided since must be greater than or equal to the current since frontier but less than or equal to the current upper frontier.

Intuitively, this method performs logical compaction. Existing entries whose time is less than since are fast-forwarded to since.

Atomically consolidates entries less than the since frontier.

Intuitively, this method performs physical compaction. Existing key–value pairs whose time is less than the since frontier are consolidated together when possible.

Reports the current since frontier.

Reports the current upper frontier.

Returns Ok if this stash instance was the leader at some point from the invocation of this method to the return of this method. Otherwise, returns Err.

Returns the stash’s epoch number. If Some, it is a positive number that increases with each start of a stash.

Reports whether the stash is in readonly mode.

In readonly mode, any attempt to mutate the stash will fail.

Provided Methods§

Returns the most recent timestamp at which sealed entries can be read.

Returns the current value of sealed entries.

Entries are iterated in (key, value) order and are guaranteed to be consolidated.

Sealed entries are those with timestamps less than the collection’s upper frontier.

Returns the current k,v pairs of sealed entries, erroring if there is more than one entry for a given key or the multiplicity is not 1 for each key.

Sealed entries are those with timestamps less than the collection’s upper frontier.

Returns the current sealed value for the given key, erroring if there is more than one entry for the key or its multiplicity is not 1.

Sealed entries are those with timestamps less than the collection’s upper frontier.

Atomically adds a single entry to the arrangement.

The entry’s time must be greater than or equal to the upper frontier.

If this method returns Ok, the entry has been made durable.

Performs multiple seals at once, potentially in a more performant way than performing the individual seals one by one.

See Stash::seal

Performs multiple compactions at once, potentially in a more performant way than performing the individual compactions one by one.

Each application of compacting a single collection must be atomic. However, there is no guarantee that Stash impls apply all compactions atomically, so it is possible that only some compactions are applied if a crash or error occurs.

See Stash::compact

Performs multiple consolidations at once, potentially in a more performant way than performing the individual consolidations one by one.

See Stash::consolidate

Implementors§