Skip to main content

MergeLadder

Struct MergeLadder 

Source
pub struct MergeLadder<M: Merger> { /* private fields */ }
Expand description

A geometric ladder of sorted, consolidated chains, merged as they arrive.

Chains are kept in order of decreasing update count, each at least twice the next, so that there are logarithmically many and each update is merged logarithmically often.

Implementations§

Source§

impl<M: Merger> MergeLadder<M>

Source

pub fn new(logger: Option<Logger>, operator_id: usize) -> Self

Allocates a new empty ladder.

The logger and operator identifier are used to report the ladder’s memory footprint, attributed to the operator that owns it.

Source

pub fn insert_chain(&mut self, chain: Vec<M::Chunk>)

Insert a chain and maintain chain properties: Chains are geometrically sized (by summed updates) and ordered by decreasing update weight.

Source

pub fn merge_all(&mut self) -> Vec<M::Chunk>

Merge all chains into a single chain, and remove it from the ladder.

Source

pub fn chains(&self) -> impl Iterator<Item = &[M::Chunk]>

The chains, largest first.

Source

pub fn retain_chains(&mut self, logic: impl FnMut(&mut Vec<M::Chunk>))

Lets logic remove updates from each chain, largest first, for batchers that release updates from the fronts of chains rather than by merging them all.

A chain keeps the weight it was pushed with, so the ladder merges as though no updates had left it, and stays logarithmic in the updates inserted. Chains left empty are removed.

Trait Implementations§

Source§

impl<M: Merger> Drop for MergeLadder<M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for MergeLadder<M>

§

impl<M> !Send for MergeLadder<M>

§

impl<M> !Sync for MergeLadder<M>

§

impl<M> !UnwindSafe for MergeLadder<M>

§

impl<M> Freeze for MergeLadder<M>
where Vec<(usize, Vec<<M as Merger>::Chunk>)>: Freeze, Vec<<M as Merger>::Chunk>: Freeze, M: Freeze,

§

impl<M> Unpin for MergeLadder<M>
where Vec<(usize, Vec<<M as Merger>::Chunk>)>: Unpin, Vec<<M as Merger>::Chunk>: Unpin, M: Unpin,

§

impl<M> UnsafeUnpin for MergeLadder<M>
where Vec<(usize, Vec<<M as Merger>::Chunk>)>: UnsafeUnpin, Vec<<M as Merger>::Chunk>: UnsafeUnpin, M: UnsafeUnpin,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<'a, S, T> Semigroup<&'a S> for T
where T: Semigroup<S>,

Source§

fn plus_equals(&mut self, rhs: &&'a S)

The method of std::ops::AddAssign, for types that do not implement AddAssign.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.