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§
Sourceconst IDENTITY: Self::PartialAggregate
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§
Sourcetype Input: InputBounds
type Input: InputBounds
Aggregator Input type that can be converted or applied to a Self::MutablePartialAggregate.
Sourcetype MutablePartialAggregate: MutablePartialAggregateType
type MutablePartialAggregate: MutablePartialAggregateType
Mutable Partial Aggregate type that can be mutated above µWheel’s low watermark.
Sourcetype PartialAggregate: PartialAggregateType
type PartialAggregate: PartialAggregateType
Immutable Partial Aggregate type that defines aggregates below µWheel’s low watermark.
Sourcetype Aggregate: Debug + Send
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§
Sourcefn lift(input: Self::Input) -> Self::MutablePartialAggregate
fn lift(input: Self::Input) -> Self::MutablePartialAggregate
Lifts Self::Input into a Self::MutablePartialAggregate
Sourcefn combine_mutable(a: &mut Self::MutablePartialAggregate, input: Self::Input)
fn combine_mutable(a: &mut Self::MutablePartialAggregate, input: Self::Input)
Combines Self::Input to an existing &mut Self::MutablePartialAggregate
.
Sourcefn freeze(a: Self::MutablePartialAggregate) -> Self::PartialAggregate
fn freeze(a: Self::MutablePartialAggregate) -> Self::PartialAggregate
Freezes a Self::MutablePartialAggregate into a Self::PartialAggregate.
Sourcefn combine(
a: Self::PartialAggregate,
b: Self::PartialAggregate,
) -> Self::PartialAggregate
fn combine( a: Self::PartialAggregate, b: Self::PartialAggregate, ) -> Self::PartialAggregate
Combine two partial aggregates and produces a new Self::PartialAggregate.
Sourcefn lower(a: Self::PartialAggregate) -> Self::Aggregate
fn lower(a: Self::PartialAggregate) -> Self::Aggregate
Lowers a Self::PartialAggregate into a final Self::Aggregate.
Provided Methods§
Sourcefn combine_inverse() -> Option<InverseFn<Self::PartialAggregate>>
fn combine_inverse() -> Option<InverseFn<Self::PartialAggregate>>
Returns a function that inverse combines two partial aggregates
Is set to None
by default
Sourcefn combine_simd() -> Option<CombineSimdFn<Self::PartialAggregate>>
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
Sourcefn compression() -> Option<Compression<Self::PartialAggregate>>
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.
impl Aggregator for AllAggregator
all
only.Source§impl Aggregator for F32AvgAggregator
Available on crate feature avg
only.
impl Aggregator for F32AvgAggregator
avg
only.Source§impl Aggregator for F64AvgAggregator
Available on crate feature avg
only.
impl Aggregator for F64AvgAggregator
avg
only.Source§impl Aggregator for I16AvgAggregator
Available on crate feature avg
only.
impl Aggregator for I16AvgAggregator
avg
only.Source§impl Aggregator for I32AvgAggregator
Available on crate feature avg
only.
impl Aggregator for I32AvgAggregator
avg
only.Source§impl Aggregator for I64AvgAggregator
Available on crate feature avg
only.
impl Aggregator for I64AvgAggregator
avg
only.Source§impl Aggregator for I128AvgAggregator
Available on crate feature avg
only.
impl Aggregator for I128AvgAggregator
avg
only.Source§impl Aggregator for U16AvgAggregator
Available on crate feature avg
only.
impl Aggregator for U16AvgAggregator
avg
only.Source§impl Aggregator for U32AvgAggregator
Available on crate feature avg
only.
impl Aggregator for U32AvgAggregator
avg
only.Source§impl Aggregator for U64AvgAggregator
Available on crate feature avg
only.
impl Aggregator for U64AvgAggregator
avg
only.Source§impl Aggregator for F32MaxAggregator
Available on crate feature max
only.
impl Aggregator for F32MaxAggregator
max
only.Source§impl Aggregator for F64MaxAggregator
Available on crate feature max
only.
impl Aggregator for F64MaxAggregator
max
only.Source§impl Aggregator for I16MaxAggregator
Available on crate feature max
only.
impl Aggregator for I16MaxAggregator
max
only.Source§impl Aggregator for I32MaxAggregator
Available on crate feature max
only.
impl Aggregator for I32MaxAggregator
max
only.Source§impl Aggregator for I64MaxAggregator
Available on crate feature max
only.
impl Aggregator for I64MaxAggregator
max
only.Source§impl Aggregator for U16MaxAggregator
Available on crate feature max
only.
impl Aggregator for U16MaxAggregator
max
only.Source§impl Aggregator for U32MaxAggregator
Available on crate feature max
only.
impl Aggregator for U32MaxAggregator
max
only.Source§impl Aggregator for U64MaxAggregator
Available on crate feature max
only.
impl Aggregator for U64MaxAggregator
max
only.Source§impl Aggregator for F32MinAggregator
Available on crate feature min
only.
impl Aggregator for F32MinAggregator
min
only.Source§impl Aggregator for F64MinAggregator
Available on crate feature min
only.
impl Aggregator for F64MinAggregator
min
only.Source§impl Aggregator for I16MinAggregator
Available on crate feature min
only.
impl Aggregator for I16MinAggregator
min
only.Source§impl Aggregator for I32MinAggregator
Available on crate feature min
only.
impl Aggregator for I32MinAggregator
min
only.Source§impl Aggregator for I64MinAggregator
Available on crate feature min
only.
impl Aggregator for I64MinAggregator
min
only.Source§impl Aggregator for U16MinAggregator
Available on crate feature min
only.
impl Aggregator for U16MinAggregator
min
only.Source§impl Aggregator for U32MinAggregator
Available on crate feature min
only.
impl Aggregator for U32MinAggregator
min
only.Source§impl Aggregator for U64MinAggregator
Available on crate feature min
only.
impl Aggregator for U64MinAggregator
min
only.Source§impl Aggregator for F32MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for F32MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = f32
type MutablePartialAggregate = <F32MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <F32MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<f32>
Source§impl Aggregator for F64MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for F64MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = f64
type MutablePartialAggregate = <F64MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <F64MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<f64>
Source§impl Aggregator for I8MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for I8MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = i8
type MutablePartialAggregate = <I8MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <I8MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<i8>
Source§impl Aggregator for I16MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for I16MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = i16
type MutablePartialAggregate = <I16MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <I16MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<i16>
Source§impl Aggregator for I32MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for I32MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = i32
type MutablePartialAggregate = <I32MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <I32MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<i32>
Source§impl Aggregator for I64MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for I64MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = i64
type MutablePartialAggregate = <I64MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <I64MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<i64>
Source§impl Aggregator for U16MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for U16MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = u16
type MutablePartialAggregate = <U16MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <U16MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<u16>
Source§impl Aggregator for U32MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for U32MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = u32
type MutablePartialAggregate = <U32MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <U32MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<u32>
Source§impl Aggregator for U64MinMaxAggregator
Available on crate feature min_max
only.
impl Aggregator for U64MinMaxAggregator
min_max
only.const IDENTITY: Self::PartialAggregate
type Input = u64
type MutablePartialAggregate = <U64MinMaxAggregator as Aggregator>::PartialAggregate
type Aggregate = <U64MinMaxAggregator as Aggregator>::PartialAggregate
type PartialAggregate = MinMaxState<u64>
Source§impl Aggregator for F32SumAggregator
Available on crate feature sum
only.
impl Aggregator for F32SumAggregator
sum
only.Source§impl Aggregator for F64SumAggregator
Available on crate feature sum
only.
impl Aggregator for F64SumAggregator
sum
only.Source§impl Aggregator for I16SumAggregator
Available on crate feature sum
only.
impl Aggregator for I16SumAggregator
sum
only.Source§impl Aggregator for I32SumAggregator
Available on crate feature sum
only.
impl Aggregator for I32SumAggregator
sum
only.Source§impl Aggregator for I64SumAggregator
Available on crate feature sum
only.
impl Aggregator for I64SumAggregator
sum
only.Source§impl Aggregator for U16SumAggregator
Available on crate feature sum
only.
impl Aggregator for U16SumAggregator
sum
only.Source§impl Aggregator for U32SumAggregator
Available on crate feature sum
only.
impl Aggregator for U32SumAggregator
sum
only.Source§impl Aggregator for U64SumAggregator
Available on crate feature sum
only.
impl Aggregator for U64SumAggregator
sum
only.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.
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,
top_n
only.