Skip to main content

InternalMerge

pub trait InternalMerge:
    Accountable
    + SizableContainer
    + Default {
    type TimeOwned;

    // Required methods
    fn len(&self) -> usize;
    fn clear(&mut self);
    fn merge_from(&mut self, others: &mut [Self], positions: &mut [usize]);
    fn extract(
        &mut self,
        position: &mut usize,
        upper: AntichainRef<'_, Self::TimeOwned>,
        frontier: &mut Antichain<Self::TimeOwned>,
        keep: &mut Self,
        ship: &mut Self,
    );

    // Provided method
    fn account(&self) -> (usize, usize, usize, usize) { ... }
}
Expand description

A container that supports the operations needed by the merge batcher: merging sorted chains and extracting updates by time.

Required Associated Types§

Source

type TimeOwned

The owned time type, for maintaining antichains.

Required Methods§

Source

fn len(&self) -> usize

The number of items in this container.

Source

fn clear(&mut self)

Clear the container for reuse.

Source

fn merge_from(&mut self, others: &mut [Self], positions: &mut [usize])

Merge items from sorted inputs into self, advancing positions. Merges until self is at capacity or all inputs are exhausted.

Dispatches based on the number of inputs:

  • 0: no-op
  • 1: bulk copy (may swap the input into self)
  • 2: merge two sorted streams
Source

fn extract( &mut self, position: &mut usize, upper: AntichainRef<'_, Self::TimeOwned>, frontier: &mut Antichain<Self::TimeOwned>, keep: &mut Self, ship: &mut Self, )

Extract updates from self into ship (times not beyond upper) and keep (times beyond upper), updating frontier with kept times.

Iteration starts at *position and advances *position as updates are consumed. The implementation must yield (return early) when either keep.at_capacity() or ship.at_capacity() becomes true, so the caller can swap out a full output buffer and resume by calling extract again. The caller invokes extract repeatedly until *position >= self.len().

This shape exists because at_capacity() for Vec is len() == capacity(), which silently becomes false again the moment a push past capacity grows the backing allocation. Without per-element yielding, a single extract call can quietly produce oversized output chunks.

Provided Methods§

Source

fn account(&self) -> (usize, usize, usize, usize)

Account the allocations behind the chunk.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D: Ord + Clone + 'static, T: Ord + Clone + PartialOrder + 'static, R: Semigroup + Clone + 'static> InternalMerge for Vec<(D, T, R)>

Source§

type TimeOwned = T

Source§

fn len(&self) -> usize

Source§

fn clear(&mut self)

Source§

fn merge_from(&mut self, others: &mut [Self], positions: &mut [usize])

Source§

fn extract( &mut self, position: &mut usize, upper: AntichainRef<'_, T>, frontier: &mut Antichain<T>, keep: &mut Self, ship: &mut Self, )

Implementors§