Trait differential_dataflow::operators::join::Join
[−]
[src]
pub trait Join<G: Scope, K: Data, V: Data> { fn join_map<V2: Data, D: Data, R: Fn(&K, &V, &V2) -> D + 'static>(
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D>; fn semijoin(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>; fn antijoin(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>; fn join_map_u<V2: Data, D: Data, R: Fn(&K, &V, &V2) -> D + 'static>(
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D>
where
K: Unsigned + Default; fn semijoin_u(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>
where
K: Unsigned + Default; fn antijoin_u(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>
where
K: Unsigned + Default; fn join<V2: Data>(
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)> { ... } fn join_u<V2: Data>(
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)>
where
K: Unsigned + Default, { ... } }
Join implementations for (key,val) data.
Required Methods
fn join_map<V2: Data, D: Data, R: Fn(&K, &V, &V2) -> D + 'static>(
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D>
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D>
Matches pairs (key,val1) and (key,val2) based on key and then applies a function.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![((0,'a'),1),((1,'B'),1)].into_iter().to_stream(scope); // should produce records `(0 + 0,'a')` and `(1 + 2,'B')`. col1.join_map(&col2, |k,v1,v2| (*k + *v1, *v2)).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,'a'),1), ((3,'B'),1)]);
fn semijoin(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>
Matches pairs (key,val1) and key based on key, filtering the first collection by values present in the second.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![(0,1)].into_iter().to_stream(scope); // should retain record `(0,0)` and discard `(1,2)`. col1.semijoin(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,0),1)]);
fn antijoin(&self, other: &Collection<G, K>) -> Collection<G, (K, V)>
Matches pairs (key,val1) and key based on key, discarding values
in the first collection if their key is present in the second.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![(0,1)].into_iter().to_stream(scope); // should retain record `(0,0)` and discard `(1,2)`. col1.semijoin(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((1,2),1)]);
fn join_map_u<V2: Data, D: Data, R: Fn(&K, &V, &V2) -> D + 'static>(
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D> where
K: Unsigned + Default,
&self,
other: &Collection<G, (K, V2)>,
logic: R
) -> Collection<G, D> where
K: Unsigned + Default,
Joins two collections with dense unsigned integer keys and then applies a map function.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![((0,'a'),1),((1,'B'),1)].into_iter().to_stream(scope); // should produce records `(0 + 0,'a')` and `(1 + 2,'B')`. col1.join_map_u(&col2, |k,v1,v2| (*k + *v1, *v2)).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,'a'),1), ((3,'B'),1)]);
fn semijoin_u(&self, other: &Collection<G, K>) -> Collection<G, (K, V)> where
K: Unsigned + Default,
K: Unsigned + Default,
Semijoins a collection with dense unsigned integer keys against a set of such keys.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![(0,1)].into_iter().to_stream(scope); // should retain record `(0,0)` and discard `(1,2)`. col1.semijoin(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,0),1)]);
fn antijoin_u(&self, other: &Collection<G, K>) -> Collection<G, (K, V)> where
K: Unsigned + Default,
K: Unsigned + Default,
Antijoins a collection with dense unsigned integer keys against a set of such keys.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![(0,1)].into_iter().to_stream(scope); // should retain record `(0,0)` and discard `(1,2)`. col1.semijoin(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,0),1)]);
Provided Methods
fn join<V2: Data>(
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)>
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)>
Matches pairs (key,val1) and (key,val2) based on key.
The join method requires that the two collections both be over pairs of records, and the
first element of the pair must be of the same type. Given two such collections, each pair
of records (key,val1) and (key,val2) with a matching key produces a (key, val1, val2)
output record.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![((0,'a'),1),((1,'B'),1)].into_iter().to_stream(scope); // should produce triples `(0,0,'a')` and `(1,2,'B')`. col1.join(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,0,'a'),1), ((1,2,'B'),1)]);
fn join_u<V2: Data>(
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)> where
K: Unsigned + Default,
&self,
other: &Collection<G, (K, V2)>
) -> Collection<G, (K, V, V2)> where
K: Unsigned + Default,
Joins two collections with dense unsigned integer keys.
Examples
extern crate timely; use timely::dataflow::operators::{ToStream, Capture}; use timely::dataflow::operators::capture::Extract; use differential_dataflow::operators::Join; let data = timely::example(|scope| { let col1 = vec![((0,0),1),((1,2),1)].into_iter().to_stream(scope); let col2 = vec![((0,'a'),1),((1,'B'),1)].into_iter().to_stream(scope); // should produce triples `(0,0,'a')` and `(1,2,'B')`. col1.join_u(&col2).capture(); }); let extracted = data.extract(); assert_eq!(extracted.len(), 1); assert_eq!(extracted[0].1, vec![((0,0,'a'),1), ((1,2,'B'),1)]);