Trait Aggregator

Source
pub trait Aggregator:
    Default
    + Debug
    + Clone
    + 'static {
    type Input: InputBounds;
    type MutablePartialAggregate: MutablePartialAggregateType;
    type PartialAggregate: PartialAggregateType;
    type Aggregate: Debug + Send;

    const IDENTITY: Self::PartialAggregate;

    // Required methods
    fn lift(input: Self::Input) -> Self::MutablePartialAggregate;
    fn combine_mutable(
        a: &mut Self::MutablePartialAggregate,
        input: Self::Input,
    );
    fn freeze(a: Self::MutablePartialAggregate) -> Self::PartialAggregate;
    fn combine(
        a: Self::PartialAggregate,
        b: Self::PartialAggregate,
    ) -> Self::PartialAggregate;
    fn lower(a: Self::PartialAggregate) -> Self::Aggregate;

    // Provided methods
    fn combine_inverse() -> Option<InverseFn<Self::PartialAggregate>> { ... }
    fn combine_simd() -> Option<CombineSimdFn<Self::PartialAggregate>> { ... }
    fn compression() -> Option<Compression<Self::PartialAggregate>> { ... }
}
Expand description

Aggregation interface that library users must implement to use µWheel

µWheel provides a bunch of pre-defined aggregator implementations including:

§Example

Here is a simple example showing how to create a SUM aggregator using u32.

use uwheel::Aggregator;

#[derive(Default, Debug, Clone)]
struct MySumAggregator;

impl Aggregator for MySumAggregator {
    const IDENTITY: Self::PartialAggregate = 0u32;
    type Input = u32;
    type MutablePartialAggregate = u32;
    type Aggregate = u32;
    type PartialAggregate = u32;

    fn lift(input: Self::Input) -> Self::MutablePartialAggregate {
       input.into()
    }

    fn combine_mutable(a: &mut Self::MutablePartialAggregate, input: Self::Input) {
       *a += input;
    }

    fn freeze(a: Self::MutablePartialAggregate) -> Self::PartialAggregate {
       a.into()
    }

    fn combine(a: Self::PartialAggregate, b: Self::PartialAggregate) -> Self::PartialAggregate {
       a + b
    }

    fn lower(a: Self::PartialAggregate) -> Self::Aggregate {
       a
    }
}

Required Associated Constants§

Source

const IDENTITY: Self::PartialAggregate

Identity value for Self::PartialAggregate.

For example, for SUM types the identity value should be set to 0.

Required Associated Types§

Source

type Input: InputBounds

Aggregator Input type that can be converted or applied to a Self::MutablePartialAggregate.

Source

type MutablePartialAggregate: MutablePartialAggregateType

Mutable Partial Aggregate type that can be mutated above µWheel’s low watermark.

Source

type PartialAggregate: PartialAggregateType

Immutable Partial Aggregate type that defines aggregates below µWheel’s low watermark.

Source

type Aggregate: Debug + Send

Final Aggregate type that can be lowered from a Self::PartialAggregate.

In many cases the Self::PartialAggregate type will be the same as Self::Aggregate. An instance where it is not is an AVG function where the partial aggregate consists of a (sum, count) tuple and the final aggregate “average” is calculated through sum/count.

Required Methods§

Source

fn lift(input: Self::Input) -> Self::MutablePartialAggregate

Source

fn combine_mutable(a: &mut Self::MutablePartialAggregate, input: Self::Input)

Combines Self::Input to an existing &mut Self::MutablePartialAggregate.

Source

fn freeze(a: Self::MutablePartialAggregate) -> Self::PartialAggregate

Source

fn combine( a: Self::PartialAggregate, b: Self::PartialAggregate, ) -> Self::PartialAggregate

Combine two partial aggregates and produces a new Self::PartialAggregate.

Source

fn lower(a: Self::PartialAggregate) -> Self::Aggregate

Lowers a Self::PartialAggregate into a final Self::Aggregate.

Provided Methods§

Source

fn combine_inverse() -> Option<InverseFn<Self::PartialAggregate>>

Returns a function that inverse combines two partial aggregates

Is set to None by default

Source

fn combine_simd() -> Option<CombineSimdFn<Self::PartialAggregate>>

Returns a function that combines a slice of partial aggregates using explicit SIMD instructions.

Is set to None by default

Source

fn compression() -> Option<Compression<Self::PartialAggregate>>

Optional compression support for partial aggregates

Is set to None by default

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.

Implementors§

Source§

impl Aggregator for AllAggregator

Available on crate feature all only.
Source§

impl Aggregator for F32AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for F64AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for I16AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for I32AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for I64AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for I128AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for U16AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for U32AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for U64AvgAggregator

Available on crate feature avg only.
Source§

impl Aggregator for F32MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0xff7fffff): <aggregator::max::F32MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f32

Source§

type MutablePartialAggregate = f32

Source§

type Aggregate = f32

Source§

type PartialAggregate = f32

Source§

impl Aggregator for F64MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0xffefffffffffffff): <aggregator::max::F64MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f64

Source§

type MutablePartialAggregate = f64

Source§

type Aggregate = f64

Source§

type PartialAggregate = f64

Source§

impl Aggregator for I16MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x8000): <aggregator::max::I16MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i16

Source§

type MutablePartialAggregate = i16

Source§

type Aggregate = i16

Source§

type PartialAggregate = i16

Source§

impl Aggregator for I32MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x80000000): <aggregator::max::I32MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i32

Source§

type MutablePartialAggregate = i32

Source§

type Aggregate = i32

Source§

type PartialAggregate = i32

Source§

impl Aggregator for I64MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x8000000000000000): <aggregator::max::I64MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i64

Source§

type MutablePartialAggregate = i64

Source§

type Aggregate = i64

Source§

type PartialAggregate = i64

Source§

impl Aggregator for U16MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000): <aggregator::max::U16MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u16

Source§

type MutablePartialAggregate = u16

Source§

type Aggregate = u16

Source§

type PartialAggregate = u16

Source§

impl Aggregator for U32MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x00000000): <aggregator::max::U32MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u32

Source§

type MutablePartialAggregate = u32

Source§

type Aggregate = u32

Source§

type PartialAggregate = u32

Source§

impl Aggregator for U64MaxAggregator

Available on crate feature max only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000000000000000): <aggregator::max::U64MaxAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u64

Source§

type MutablePartialAggregate = u64

Source§

type Aggregate = u64

Source§

type PartialAggregate = u64

Source§

impl Aggregator for F32MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x7f7fffff): <aggregator::min::F32MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f32

Source§

type MutablePartialAggregate = f32

Source§

type Aggregate = f32

Source§

type PartialAggregate = f32

Source§

impl Aggregator for F64MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x7fefffffffffffff): <aggregator::min::F64MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f64

Source§

type MutablePartialAggregate = f64

Source§

type Aggregate = f64

Source§

type PartialAggregate = f64

Source§

impl Aggregator for I16MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x7fff): <aggregator::min::I16MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i16

Source§

type MutablePartialAggregate = i16

Source§

type Aggregate = i16

Source§

type PartialAggregate = i16

Source§

impl Aggregator for I32MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x7fffffff): <aggregator::min::I32MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i32

Source§

type MutablePartialAggregate = i32

Source§

type Aggregate = i32

Source§

type PartialAggregate = i32

Source§

impl Aggregator for I64MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x7fffffffffffffff): <aggregator::min::I64MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i64

Source§

type MutablePartialAggregate = i64

Source§

type Aggregate = i64

Source§

type PartialAggregate = i64

Source§

impl Aggregator for U16MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0xffff): <aggregator::min::U16MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u16

Source§

type MutablePartialAggregate = u16

Source§

type Aggregate = u16

Source§

type PartialAggregate = u16

Source§

impl Aggregator for U32MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0xffffffff): <aggregator::min::U32MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u32

Source§

type MutablePartialAggregate = u32

Source§

type Aggregate = u32

Source§

type PartialAggregate = u32

Source§

impl Aggregator for U64MinAggregator

Available on crate feature min only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0xffffffffffffffff): <aggregator::min::U64MinAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u64

Source§

type MutablePartialAggregate = u64

Source§

type Aggregate = u64

Source§

type PartialAggregate = u64

Source§

impl Aggregator for F32MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for F64MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for I8MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for I16MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for I32MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for I64MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for U16MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for U32MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for U64MinMaxAggregator

Available on crate feature min_max only.
Source§

impl Aggregator for F32SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x00000000): <aggregator::sum::F32SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f32

Source§

type MutablePartialAggregate = f32

Source§

type Aggregate = f32

Source§

type PartialAggregate = f32

Source§

impl Aggregator for F64SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000000000000000): <aggregator::sum::F64SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = f64

Source§

type MutablePartialAggregate = f64

Source§

type Aggregate = f64

Source§

type PartialAggregate = f64

Source§

impl Aggregator for I16SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000): <aggregator::sum::I16SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i16

Source§

type MutablePartialAggregate = i16

Source§

type Aggregate = i16

Source§

type PartialAggregate = i16

Source§

impl Aggregator for I32SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x00000000): <aggregator::sum::I32SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i32

Source§

type MutablePartialAggregate = i32

Source§

type Aggregate = i32

Source§

type PartialAggregate = i32

Source§

impl Aggregator for I64SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000000000000000): <aggregator::sum::I64SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = i64

Source§

type MutablePartialAggregate = i64

Source§

type Aggregate = i64

Source§

type PartialAggregate = i64

Source§

impl Aggregator for U16SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000): <aggregator::sum::U16SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u16

Source§

type MutablePartialAggregate = u16

Source§

type Aggregate = u16

Source§

type PartialAggregate = u16

Source§

impl Aggregator for U32SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x00000000): <aggregator::sum::U32SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u32

Source§

type MutablePartialAggregate = u32

Source§

type Aggregate = u32

Source§

type PartialAggregate = u32

Source§

impl Aggregator for U64SumAggregator

Available on crate feature sum only.
Source§

const IDENTITY: Self::PartialAggregate = {transmute(0x0000000000000000): <aggregator::sum::U64SumAggregator as aggregator::Aggregator>::PartialAggregate}

Source§

type Input = u64

Source§

type MutablePartialAggregate = u64

Source§

type Aggregate = u64

Source§

type PartialAggregate = u64

Source§

impl<Key, const N: usize, A, OrderBy> Aggregator for TopNAggregator<Key, N, A, OrderBy>
where Key: KeyBounds, OrderBy: Order, A: Aggregator + Clone + Copy, A::PartialAggregate: Ord + Copy,

Available on crate feature top_n only.