pub struct CrossPartitionAggregateStore { /* private fields */ }Expand description
Lock-free concurrent store for cross-partition partial aggregates.
Each partition publishes serialized partial aggregates under its
partition_id. Readers merge partials for a given group key to
produce the final aggregate.
§Performance
- Write (publish partial): single
papaya::HashMap::insert— lock-free - Read (get partial): single
papaya::HashMap::get— lock-free - Merge: iterate known partitions, collect partials, caller merges
Implementations§
Source§impl CrossPartitionAggregateStore
impl CrossPartitionAggregateStore
Sourcepub fn publish(&self, group_key: Bytes, partition_id: u32, partial: Bytes)
pub fn publish(&self, group_key: Bytes, partition_id: u32, partial: Bytes)
Publish a partial aggregate from a partition.
Overwrites any previous partial for this (group_key, partition_id).
Sourcepub fn get_partial(&self, group_key: &[u8], partition_id: u32) -> Option<Bytes>
pub fn get_partial(&self, group_key: &[u8], partition_id: u32) -> Option<Bytes>
Get the partial aggregate for a specific partition.
Sourcepub fn collect_partials(&self, group_key: &[u8]) -> Vec<(u32, Bytes)>
pub fn collect_partials(&self, group_key: &[u8]) -> Vec<(u32, Bytes)>
Collect all partial aggregates for a group key across all partitions.
Returns a vector of (partition_id, partial_bytes) for all
partitions that have published a partial for this key.
Sourcepub fn remove_group(&self, group_key: &[u8])
pub fn remove_group(&self, group_key: &[u8])
Remove all partials for a group key.
Sourcepub fn num_partitions(&self) -> u32
pub fn num_partitions(&self) -> u32
Total number of partitions.
Sourcepub fn snapshot(&self) -> Vec<(Vec<u8>, Vec<u8>)>
pub fn snapshot(&self) -> Vec<(Vec<u8>, Vec<u8>)>
Snapshot all partial aggregates for checkpointing.
Each entry is serialized as:
- Key:
group_key_len(4 bytes LE) + group_key + partition_id(4 bytes LE) - Value: raw partial aggregate bytes
The num_partitions is stored as a sentinel entry with an empty key
and value containing the partition count as 4 bytes LE.
Sourcepub fn restore(&self, snapshot: &[(Vec<u8>, Vec<u8>)])
pub fn restore(&self, snapshot: &[(Vec<u8>, Vec<u8>)])
Restore partial aggregates from a checkpoint snapshot.
Clears the current state and inserts all entries from the snapshot.
§Panics
Panics if a non-sentinel entry has a key shorter than the encoded length prefix (corrupted snapshot). Malformed entries with incorrect total length are silently skipped.
Auto Trait Implementations§
impl !Freeze for CrossPartitionAggregateStore
impl RefUnwindSafe for CrossPartitionAggregateStore
impl Send for CrossPartitionAggregateStore
impl Sync for CrossPartitionAggregateStore
impl Unpin for CrossPartitionAggregateStore
impl UnsafeUnpin for CrossPartitionAggregateStore
impl !UnwindSafe for CrossPartitionAggregateStore
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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