Reduce

Trait Reduce 

Source
pub trait Reduce<G: Scope<Timestamp: Lattice + Ord>, K: Data, V: Data, R: Semigroup> {
    // Required method
    fn reduce_named<L, V2: Data, R2: Ord + Abelian + 'static>(
        &self,
        name: &str,
        logic: L,
    ) -> Collection<G, (K, V2), R2>
       where L: FnMut(&K, &[(&V, R)], &mut Vec<(V2, R2)>) + 'static;

    // Provided method
    fn reduce<L, V2: Data, R2: Ord + Abelian + 'static>(
        &self,
        logic: L,
    ) -> Collection<G, (K, V2), R2>
       where L: FnMut(&K, &[(&V, R)], &mut Vec<(V2, R2)>) + 'static { ... }
}
Expand description

Extension trait for the reduce differential dataflow method.

Required Methods§

Source

fn reduce_named<L, V2: Data, R2: Ord + Abelian + 'static>( &self, name: &str, logic: L, ) -> Collection<G, (K, V2), R2>
where L: FnMut(&K, &[(&V, R)], &mut Vec<(V2, R2)>) + 'static,

As reduce with the ability to name the operator.

Provided Methods§

Source

fn reduce<L, V2: Data, R2: Ord + Abelian + 'static>( &self, logic: L, ) -> Collection<G, (K, V2), R2>
where L: FnMut(&K, &[(&V, R)], &mut Vec<(V2, R2)>) + 'static,

Applies a reduction function on records grouped by key.

Input data must be structured as (key, val) pairs. The user-supplied reduction function takes as arguments

  1. a reference to the key,
  2. a reference to the slice of values and their accumulated updates,
  3. a mutuable reference to a vector to populate with output values and accumulated updates.

The user logic is only invoked for non-empty input collections, and it is safe to assume that the slice of input values is non-empty. The values are presented in sorted order, as defined by their Ord implementations.

§Examples
use differential_dataflow::input::Input;
use differential_dataflow::operators::Reduce;

::timely::example(|scope| {
    // report the smallest value for each group
    scope.new_collection_from(1 .. 10).1
         .map(|x| (x / 3, x))
         .reduce(|_key, input, output| {
             output.push((*input[0].0, 1))
         });
});

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<G, K, V, R> Reduce<G, K, V, R> for Collection<G, (K, V), R>
where G: Scope<Timestamp: Lattice + Ord>, K: ExchangeData + Hashable, V: ExchangeData, R: ExchangeData + Semigroup,

Source§

impl<G, K: Data, V: Data, T1, R: Ord + Semigroup + 'static> Reduce<G, K, V, R> for Arranged<G, T1>
where G: Scope<Timestamp = T1::Time>, T1: for<'a> TraceReader<Key<'a> = &'a K, KeyOwn = K, Val<'a> = &'a V, Diff = R> + Clone + 'static,