Skip to main content

Aggregate

Struct Aggregate 

Source
pub struct Aggregate<N, K, L, W, WV, A>
where N: Field, K: Field, L: Field, W: Field, WV: WeightValue, A: Field,
{ pub items: usize, pub names: BTreeMap<N, usize>, pub kinds: BTreeMap<K, usize>, pub labels: BTreeMap<L, usize>, pub weights: BTreeMap<W, WV>, pub annotations: BTreeMap<A, usize>, }
Expand description

Metadata aggregate values.

Fields§

§items: usize

Over how many items the aggregate has been taken.

§names: BTreeMap<N, usize>

Name occurrence.

§kinds: BTreeMap<K, usize>

Kind occurrence.

§labels: BTreeMap<L, usize>

Label occurrence.

§weights: BTreeMap<W, WV>

Weight sum value.

§annotations: BTreeMap<A, usize>

Annotation key occurrence.

Implementations§

Source§

impl<N, K, L, W, WV, A> Aggregate<N, K, L, W, WV, A>
where N: Field, K: Field, L: Field, W: Field, WV: WeightValue, A: Field,

Source

pub fn builder() -> AggregateBuilder<N, K, L, W, WV, A>

Create an instance of Aggregate using the builder syntax

Source§

impl<N, K, L, W, WV, A> Aggregate<N, K, L, W, WV, A>
where N: Field, K: Field, L: Field, W: Field, WV: WeightValue, A: Field,

Source

pub fn new() -> Self

Create a new aggregate instance.

Source

pub fn add<'a, M: ReadMetadata<'a, N, K, L, W, WV, A, AV>, AV: 'a + AnnotationValue>( &'a mut self, item: &'a M, )

Add metadata to the aggregate.

Source

pub fn subtract<'a, M: ReadMetadata<'a, N, K, L, W, WV, A, AV>, AV: 'a + AnnotationValue>( &'a mut self, item: &'a M, )

Subtract metadata from the aggregate.

Source

pub fn extend(&mut self, other: Self)

Add another Aggregate’s values to this.

Source

pub fn aggregate(&self, aggregator: &Aggregator<N, K, L, W, A>) -> f64

Get the sum for all given fields’ values for a given aggregator.

Source

pub fn fraction(&self, aggregator: &Aggregator<N, K, L, W, A>) -> f64

Get a fraction that a field represents with respect to the sum of all fields for a certain aggregator.

Source

pub fn fractions( &self, aggregator: &Aggregator<N, K, L, W, A>, factor: f64, ) -> Vec<f64>

Get all fractions for the given fields with respect to the sum of all fields for a certain aggregator. It can be scaled with a constant factor. Set the factor to 1.0 to ignore scaling.

Trait Implementations§

Source§

impl<N, K, L, W, WV, A> Clone for Aggregate<N, K, L, W, WV, A>
where N: Field + Clone, K: Field + Clone, L: Field + Clone, W: Field + Clone, WV: WeightValue + Clone, A: Field + Clone,

Source§

fn clone(&self) -> Aggregate<N, K, L, W, WV, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N, K, L, W, WV, A> Debug for Aggregate<N, K, L, W, WV, A>
where N: Field + Debug, K: Field + Debug, L: Field + Debug, W: Field + Debug, WV: WeightValue + Debug, A: Field + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N, K, L, W, WV, A> Default for Aggregate<N, K, L, W, WV, A>
where N: Field, K: Field, L: Field, W: Field, WV: WeightValue, A: Field,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, N, K, L, W, WV, A> Deserialize<'de> for Aggregate<N, K, L, W, WV, A>
where N: Field + Deserialize<'de>, K: Field + Deserialize<'de>, L: Field + Deserialize<'de>, W: Field + Deserialize<'de>, WV: WeightValue + Deserialize<'de>, A: Field + Deserialize<'de>, Aggregate<N, K, L, W, WV, A>: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<N, K, L, W, WV, A> PartialEq for Aggregate<N, K, L, W, WV, A>

Source§

fn eq(&self, other: &Aggregate<N, K, L, W, WV, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N, K, L, W, WV, A> Serialize for Aggregate<N, K, L, W, WV, A>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<N, K, L, W, WV, A> StructuralPartialEq for Aggregate<N, K, L, W, WV, A>
where N: Field, K: Field, L: Field, W: Field, WV: WeightValue, A: Field,

Auto Trait Implementations§

§

impl<N, K, L, W, WV, A> Freeze for Aggregate<N, K, L, W, WV, A>

§

impl<N, K, L, W, WV, A> RefUnwindSafe for Aggregate<N, K, L, W, WV, A>

§

impl<N, K, L, W, WV, A> Send for Aggregate<N, K, L, W, WV, A>
where N: Send, K: Send, L: Send, W: Send, WV: Send, A: Send,

§

impl<N, K, L, W, WV, A> Sync for Aggregate<N, K, L, W, WV, A>
where N: Sync, K: Sync, L: Sync, W: Sync, WV: Sync, A: Sync,

§

impl<N, K, L, W, WV, A> Unpin for Aggregate<N, K, L, W, WV, A>

§

impl<N, K, L, W, WV, A> UnsafeUnpin for Aggregate<N, K, L, W, WV, A>

§

impl<N, K, L, W, WV, A> UnwindSafe for Aggregate<N, K, L, W, WV, A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> AnnotationValue for T
where T: Debug + Clone + PartialEq,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,