Skip to content

Commit e0add72

Browse files
Extract VecCollection from Collection (#651)
* Extract CollectionCore from Collection * VecCollection * Correct cargo doc glitches
1 parent 1e242f6 commit e0add72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+448
-456
lines changed

advent_of_code_2017/src/bin/day_07.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate differential_dataflow;
33

44
// taken from: https://adventofcode.com/2017/day/6
55

6-
use differential_dataflow::Collection;
6+
use differential_dataflow::VecCollection;
77
use differential_dataflow::input::Input;
88
use differential_dataflow::operators::*;
99

@@ -1074,7 +1074,7 @@ tvhftq (35)";
10741074
let index = worker.index();
10751075
let peers = worker.peers();
10761076

1077-
let worker_input =
1077+
let worker_input =
10781078
input
10791079
.split('\n')
10801080
.enumerate()
@@ -1102,7 +1102,7 @@ tvhftq (35)";
11021102
let weights = input.explode(|(name,weight,_)| Some((name, weight as isize)));
11031103
let parents = input.flat_map(|(name,_,links)| links.into_iter().map(move |link| (link,name.to_string())));
11041104

1105-
let total_weights: Collection<_,String> = weights
1105+
let total_weights: VecCollection<_,String> = weights
11061106
.iterate(|inner| {
11071107
parents.enter(&inner.scope())
11081108
.semijoin(&inner)

advent_of_code_2017/src/bin/day_08.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate differential_dataflow;
33

44
// taken from: https://adventofcode.com/2017/day/8
55

6-
// use differential_dataflow::Collection;
6+
// use differential_dataflow::VecCollection;
77
use differential_dataflow::input::Input;
88
use differential_dataflow::operators::*;
99
use differential_dataflow::algorithms::prefix_sum::PrefixSum;
@@ -1068,7 +1068,7 @@ wui inc -120 if i > -2038";
10681068
let edits = data.map(|(pos, line)| {
10691069

10701070
// Each line has a read location with a condition, and a write location with an operation.
1071-
// E.g.,
1071+
// E.g.,
10721072
//
10731073
// kxm dec 986 if xbh <= -2515
10741074
// obc inc 63 if wui >= 2800

advent_of_code_2017/src/bin/day_09.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
let index = worker.index();
2121
let peers = worker.peers();
2222

23-
let worker_input =
23+
let worker_input =
2424
input
2525
.chars()
2626
.enumerate()
@@ -37,7 +37,7 @@ fn main() {
3737
// { next_invalid, garbage }
3838
//
3939
// where the first bool indicates that the next character should be ignored,
40-
// and the second bool indicates that we are in a garbage scope. We will
40+
// and the second bool indicates that we are in a garbage scope. We will
4141
// encode this as the values 0 .. 4, where
4242
//
4343
// 0: valid, non-garbage
@@ -48,7 +48,7 @@ fn main() {
4848
// Each character initially describes a substring of length one, but we will
4949
// build up the state transition for larger substrings, iteratively.
5050

51-
let transitions =
51+
let transitions =
5252
input
5353
.map(|(pos, character)|
5454
(pos, match character {
@@ -95,7 +95,7 @@ fn main() {
9595
}
9696

9797
/// Accumulate data in `collection` into all powers-of-two intervals containing them.
98-
fn pp_aggregate<G, D, F>(collection: Collection<G, (usize, D)>, combine: F) -> Collection<G, ((usize, usize), D)>
98+
fn pp_aggregate<G, D, F>(collection: VecCollection<G, (usize, D)>, combine: F) -> VecCollection<G, ((usize, usize), D)>
9999
where
100100
G: Scope<Timestamp: Lattice>,
101101
D: Data,
@@ -105,7 +105,7 @@ where
105105
let unit_ranges = collection.map(|(index, data)| ((index, 0), data));
106106

107107
unit_ranges
108-
.iterate(|ranges|
108+
.iterate(|ranges|
109109

110110
// Each available range, of size less than usize::max_value(), advertises itself as the range
111111
// twice as large, aligned to integer multiples of its size. Each range, which may contain at
@@ -126,26 +126,26 @@ where
126126

127127
/// Produces the accumulated values at each of the `usize` locations in `aggregates` (and others).
128128
fn pp_broadcast<G, D, B, F>(
129-
ranges: Collection<G, ((usize, usize), D)>,
129+
ranges: VecCollection<G, ((usize, usize), D)>,
130130
seed: B,
131131
zero: D,
132-
combine: F) -> Collection<G, (usize, B)>
132+
combine: F) -> VecCollection<G, (usize, B)>
133133
where
134134
G: Scope<Timestamp: Lattice+Ord+::std::fmt::Debug>,
135135
D: Data,
136136
B: Data+::std::hash::Hash,
137137
F: Fn(&B, &D) -> B + 'static,
138138
{
139139
// Each range proposes an empty first child, to provide for its second child if it has no sibling.
140-
// This is important if we want to reconstruct
140+
// This is important if we want to reconstruct
141141
let zero_ranges =
142142
ranges
143143
.map(move |((pos, log),_)| ((pos, if log > 0 { log - 1 } else { 0 }), zero.clone()))
144144
.antijoin(&ranges.map(|((pos, log),_)| (pos, log)));
145145

146146
let aggregates = ranges.concat(&zero_ranges);
147147

148-
let init_state =
148+
let init_state =
149149
Some(((0, seed), Default::default(), 1))
150150
.to_stream(&mut aggregates.scope())
151151
.as_collection();

advent_of_code_2017/src/bin/day_10.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate differential_dataflow;
33

44
// taken from: https://adventofcode.com/2017/day/8
55

6-
use differential_dataflow::Collection;
6+
use differential_dataflow::VecCollection;
77
use differential_dataflow::input::Input;
88
use differential_dataflow::operators::*;
99

@@ -61,4 +61,4 @@ fn knot_step<I: Iterator<Item=u8>+Clone>(iter: I, rounds: usize) -> Vec<u8> {
6161
}
6262

6363
state
64-
}
64+
}

advent_of_code_2017/src/bin/day_14.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate differential_dataflow;
33

44
// taken from: https://adventofcode.com/2017/day/8
55

6-
use differential_dataflow::Collection;
6+
use differential_dataflow::VecCollection;
77
use differential_dataflow::input::Input;
88
use differential_dataflow::operators::*;
99

@@ -31,8 +31,8 @@ fn main() {
3131
// println!("{:?}: \t{:?}", row, hash);
3232

3333
(0 .. 128)
34-
.map(move |col|
35-
if hash[col/8] & (1 << (7-(col % 8))) != 0 {
34+
.map(move |col|
35+
if hash[col/8] & (1 << (7-(col % 8))) != 0 {
3636
(row, col, '#')
3737
}
3838
else {
@@ -92,4 +92,4 @@ fn knot_step<I: Iterator<Item=u8>+Clone>(iter: I, rounds: usize) -> Vec<u8> {
9292
}
9393

9494
state
95-
}
95+
}

advent_of_code_2017/src/bin/day_15.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate differential_dataflow;
33

44
// taken from: https://adventofcode.com/2017/day/8
55

6-
use differential_dataflow::Collection;
6+
use differential_dataflow::VecCollection;
77
use differential_dataflow::input::Input;
88
use differential_dataflow::operators::*;
99

@@ -43,4 +43,4 @@ fn main() {
4343

4444
println!("part2: {:?}", equal);
4545

46-
}
46+
}

differential-dataflow/examples/bfs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use timely::dataflow::*;
44
use timely::dataflow::operators::probe::Handle;
55

66
use differential_dataflow::input::Input;
7-
use differential_dataflow::Collection;
7+
use differential_dataflow::VecCollection;
88
use differential_dataflow::operators::*;
99
use differential_dataflow::lattice::Lattice;
1010

@@ -91,9 +91,9 @@ fn main() {
9191
}
9292

9393
// returns pairs (n, s) indicating node n can be reached from a root in s steps.
94-
fn bfs<G>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
94+
fn bfs<G>(edges: &VecCollection<G, Edge>, roots: &VecCollection<G, Node>) -> VecCollection<G, (Node, u32)>
9595
where
96-
G: Scope<Timestamp: Lattice+Ord>,
96+
G: Scope<Timestamp: Lattice+Ord>,
9797
{
9898
// initialize roots as reaching themselves at distance 0
9999
let nodes = roots.map(|x| (x, 0));
@@ -108,4 +108,4 @@ where
108108
.concat(&nodes)
109109
.reduce(|_, s, t| t.push((*s[0].0, 1)))
110110
})
111-
}
111+
}

differential-dataflow/examples/dynamic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use timely::dataflow::*;
44
use timely::dataflow::operators::probe::Handle;
55

66
use differential_dataflow::input::Input;
7-
use differential_dataflow::Collection;
7+
use differential_dataflow::VecCollection;
88
use differential_dataflow::operators::*;
99
use differential_dataflow::lattice::Lattice;
1010

@@ -91,9 +91,9 @@ fn main() {
9191
}
9292

9393
// returns pairs (n, s) indicating node n can be reached from a root in s steps.
94-
fn bfs<G>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
94+
fn bfs<G>(edges: &VecCollection<G, Edge>, roots: &VecCollection<G, Node>) -> VecCollection<G, (Node, u32)>
9595
where
96-
G: Scope<Timestamp: Lattice+Ord>,
96+
G: Scope<Timestamp: Lattice+Ord>,
9797
{
9898
use timely::order::Product;
9999
use iterate::Variable;
@@ -115,7 +115,7 @@ where
115115
let inner = feedback_summary::<usize>(1, 1);
116116
let label = Variable::new_from(nodes.clone(), Product { outer: Default::default(), inner });
117117

118-
let next =
118+
let next =
119119
label
120120
.join_map(&edges, |_k,l,d| (*d, l+1))
121121
.concat(&nodes)
@@ -130,4 +130,4 @@ where
130130
.leave()
131131
})
132132

133-
}
133+
}

differential-dataflow/examples/graspan.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use timely::order::Product;
88
use timely::dataflow::Scope;
99
use timely::dataflow::scopes::ScopeParent;
1010

11-
use differential_dataflow::Collection;
11+
use differential_dataflow::VecCollection;
1212
use differential_dataflow::lattice::Lattice;
1313
use differential_dataflow::input::{Input, InputSession};
1414
use differential_dataflow::operators::arrange::{ArrangeByKey, ArrangeBySelf};
15-
use differential_dataflow::operators::iterate::Variable;
15+
use differential_dataflow::operators::iterate::VecVariable;
1616
use differential_dataflow::operators::Threshold;
1717

1818
type Node = usize;
@@ -83,16 +83,16 @@ type Arrange<G,K,V,R> = Arranged<G, TraceValHandle<K, V, <G as ScopeParent>::Tim
8383
/// An edge variable provides arranged representations of its contents, even before they are
8484
/// completely defined, in support of recursively defined productions.
8585
pub struct EdgeVariable<G: Scope<Timestamp: Lattice>> {
86-
variable: Variable<G, Edge, Diff>,
87-
current: Collection<G, Edge, Diff>,
86+
variable: VecVariable<G, Edge, Diff>,
87+
current: VecCollection<G, Edge, Diff>,
8888
forward: Option<Arrange<G, Node, Node, Diff>>,
8989
reverse: Option<Arrange<G, Node, Node, Diff>>,
9090
}
9191

9292
impl<G: Scope<Timestamp: Lattice>> EdgeVariable<G> {
9393
/// Creates a new variable initialized with `source`.
94-
pub fn from(source: &Collection<G, Edge>, step: <G::Timestamp as Timestamp>::Summary) -> Self {
95-
let variable = Variable::new(&mut source.scope(), step);
94+
pub fn from(source: &VecCollection<G, Edge>, step: <G::Timestamp as Timestamp>::Summary) -> Self {
95+
let variable = VecVariable::new(&mut source.scope(), step);
9696
EdgeVariable {
9797
variable: variable,
9898
current: source.clone(),
@@ -101,7 +101,7 @@ impl<G: Scope<Timestamp: Lattice>> EdgeVariable<G> {
101101
}
102102
}
103103
/// Concatenates `production` into the definition of the variable.
104-
pub fn add_production(&mut self, production: &Collection<G, Edge, Diff>) {
104+
pub fn add_production(&mut self, production: &VecCollection<G, Edge, Diff>) {
105105
self.current = self.current.concat(production);
106106
}
107107
/// Finalizes the variable, connecting its recursive definition.
@@ -153,7 +153,7 @@ impl Query {
153153

154154
/// Creates a dataflow implementing the query, and returns input and trace handles.
155155
pub fn render_in<G>(&self, scope: &mut G) -> IndexMap<String, RelationHandles<G::Timestamp>>
156-
where
156+
where
157157
G: Scope<Timestamp: Lattice+::timely::order::TotalOrder>,
158158
{
159159
// Create new input (handle, stream) pairs

differential-dataflow/examples/interpreted.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::hash::Hash;
22
use timely::dataflow::*;
33
use timely::dataflow::operators::*;
44

5-
use differential_dataflow::Collection;
5+
use differential_dataflow::VecCollection;
66
use differential_dataflow::lattice::Lattice;
77
use differential_dataflow::operators::*;
88

@@ -35,13 +35,13 @@ fn main() {
3535
println!("loaded {} nodes, {} edges", nodes, edges.len());
3636

3737
worker.dataflow::<(),_,_>(|scope| {
38-
interpret(&Collection::new(edges.to_stream(scope)), &[(0,2), (1,2)]);
38+
interpret(&VecCollection::new(edges.to_stream(scope)), &[(0,2), (1,2)]);
3939
});
4040

4141
}).unwrap();
4242
}
4343

44-
fn interpret<G>(edges: &Collection<G, Edge>, relations: &[(usize, usize)]) -> Collection<G, Vec<Node>>
44+
fn interpret<G>(edges: &VecCollection<G, Edge>, relations: &[(usize, usize)]) -> VecCollection<G, Vec<Node>>
4545
where
4646
G: Scope<Timestamp: Lattice+Hash+Ord>,
4747
{
@@ -103,4 +103,4 @@ where
103103
}
104104

105105
results
106-
}
106+
}

0 commit comments

Comments
 (0)