[][src]Trait differential_dataflow::operators::reduce::Reduce

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

Extension trait for the reduce differential dataflow method.

Required methods

fn reduce_named<L, V2: Data, R2: Abelian>(
    &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.

Loading content...

Provided methods

fn reduce<L, V2: Data, R2: Abelian>(
    &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

extern crate timely;
extern crate differential_dataflow;

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

fn main() {
    ::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))
             });
    });
}
Loading content...

Implementors

impl<G, K, V, R> Reduce<G, K, V, R> for Collection<G, (K, V), R> where
    G: Scope,
    G::Timestamp: Lattice + Ord,
    K: ExchangeData + Hashable,
    V: ExchangeData,
    R: ExchangeData + Semigroup
[src]

impl<G: Scope, K: Data, V: Data, T1, R: Semigroup> Reduce<G, K, V, R> for Arranged<G, T1> where
    G::Timestamp: Lattice + Ord,
    T1: TraceReader<Key = K, Val = V, Time = G::Timestamp, R = R> + Clone + 'static,
    T1::Batch: BatchReader<K, V, G::Timestamp, R>,
    T1::Cursor: Cursor<K, V, G::Timestamp, R>, 
[src]

Loading content...