Skip to content

Commit 96079f8

Browse files
committed
Owned streams take 2
Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent 08eca72 commit 96079f8

Some content is hidden

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

51 files changed

+553
-366
lines changed

container/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ pub mod flatcontainer;
1414
///
1515
/// A container must implement default. The default implementation is not required to allocate
1616
/// memory for variable-length components.
17-
///
18-
/// We require the container to be cloneable to enable efficient copies when providing references
19-
/// of containers to operators. Care must be taken that the type's `clone_from` implementation
20-
/// is efficient (which is not necessarily the case when deriving `Clone`.)
2117
pub trait Container: Default {
2218
/// The type of elements when reading non-destructively from the container.
2319
type ItemRef<'a> where Self: 'a;
@@ -105,7 +101,7 @@ pub trait PushInto<T> {
105101
/// decide to represent a push order for `extract` and `finish`, or not.
106102
pub trait ContainerBuilder: Default + 'static {
107103
/// The container type we're building.
108-
type Container: Container + Clone + 'static;
104+
type Container: Container + 'static;
109105
/// Extract assembled containers, potentially leaving unfinished data behind. Can
110106
/// be called repeatedly, for example while the caller can send data.
111107
///
@@ -170,7 +166,7 @@ impl<T, C: SizableContainer + PushInto<T>> PushInto<T> for CapacityContainerBuil
170166
}
171167
}
172168

173-
impl<C: Container + Clone + 'static> ContainerBuilder for CapacityContainerBuilder<C> {
169+
impl<C: Container + 'static> ContainerBuilder for CapacityContainerBuilder<C> {
174170
type Container = C;
175171

176172
#[inline]

mdbook/src/chapter_2/chapter_2_3.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ use timely::dataflow::operators::{ToStream, Partition, Inspect};
126126

127127
fn main() {
128128
timely::example(|scope| {
129-
let streams = (0..10).to_stream(scope)
129+
let mut streams = (0..10).to_stream(scope)
130130
.partition(3, |x| (x % 3, x));
131131

132-
streams[0].inspect(|x| println!("seen 0: {:?}", x));
133-
streams[1].inspect(|x| println!("seen 1: {:?}", x));
134-
streams[2].inspect(|x| println!("seen 2: {:?}", x));
132+
streams.pop().unwrap().inspect(|x| println!("seen 2: {:?}", x));
133+
streams.pop().unwrap().inspect(|x| println!("seen 1: {:?}", x));
134+
streams.pop().unwrap().inspect(|x| println!("seen 0: {:?}", x));
135135
});
136136
}
137137
```
@@ -147,11 +147,11 @@ use timely::dataflow::operators::{ToStream, Partition, Concat, Inspect};
147147

148148
fn main() {
149149
timely::example(|scope| {
150-
let streams = (0..10).to_stream(scope)
150+
let mut streams = (0..10).to_stream(scope)
151151
.partition(3, |x| (x % 3, x));
152-
streams[0]
153-
.concat(&streams[1])
154-
.concat(&streams[2])
152+
streams.pop().unwrap()
153+
.concat(streams.pop().unwrap())
154+
.concat(streams.pop().unwrap())
155155
.inspect(|x| println!("seen: {:?}", x));
156156
});
157157
}

mdbook/src/chapter_2/chapter_2_4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn main() {
182182
let in1 = (0 .. 10).to_stream(scope);
183183
let in2 = (0 .. 10).to_stream(scope);
184184

185-
in1.binary_frontier(&in2, Pipeline, Pipeline, "concat_buffer", |capability, info| {
185+
in1.binary_frontier(in2, Pipeline, Pipeline, "concat_buffer", |capability, info| {
186186

187187
let mut notificator = FrontierNotificator::default();
188188
let mut stash = HashMap::new();
@@ -233,7 +233,7 @@ fn main() {
233233
let in1 = (0 .. 10).to_stream(scope);
234234
let in2 = (0 .. 10).to_stream(scope);
235235

236-
in1.binary_frontier(&in2, Pipeline, Pipeline, "concat_buffer", |capability, info| {
236+
in1.binary_frontier(in2, Pipeline, Pipeline, "concat_buffer", |capability, info| {
237237

238238
let mut stash = HashMap::new();
239239

mdbook/src/chapter_4/chapter_4_2.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
// circulate numbers, Collatz stepping each time.
2525
(1 .. 10)
2626
.to_stream(scope)
27-
.concat(&stream)
27+
.concat(stream)
2828
.map(|x| if x % 2 == 0 { x / 2 } else { 3 * x + 1 } )
2929
.inspect(|x| println!("{:?}", x))
3030
.filter(|x| *x != 1)
@@ -63,17 +63,17 @@ fn main() {
6363
let results1 = stream1.map(|x| 3 * x + 1);
6464

6565
// partition the input and feedback streams by even-ness.
66-
let parts =
66+
let mut parts =
6767
(1 .. 10)
6868
.to_stream(scope)
69-
.concat(&results0)
70-
.concat(&results1)
69+
.concat(results0)
70+
.concat(results1)
7171
.inspect(|x| println!("{:?}", x))
7272
.partition(2, |x| (x % 2, x));
7373

7474
// connect each part appropriately.
75-
parts[0].connect_loop(handle0);
76-
parts[1].connect_loop(handle1);
75+
parts.pop().unwrap().connect_loop(handle1);
76+
parts.pop().unwrap().connect_loop(handle0);
7777
});
7878
}
7979
```
@@ -103,7 +103,7 @@ fn main() {
103103

104104
input
105105
.enter(subscope)
106-
.concat(&stream)
106+
.concat(stream)
107107
.map(|x| if x % 2 == 0 { x / 2 } else { 3 * x + 1 } )
108108
.inspect(|x| println!("{:?}", x))
109109
.filter(|x| *x != 1)

mdbook/src/chapter_4/chapter_4_3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn main() {
7676
// Assign timestamps to records so that not much work is in each time.
7777
.delay(|number, time| number / 100 )
7878
// Buffer records until all prior timestamps have completed.
79-
.binary_frontier(&cycle, Pipeline, Pipeline, "Buffer", move |capability, info| {
79+
.binary_frontier(cycle, Pipeline, Pipeline, "Buffer", move |capability, info| {
8080
8181
move |input1, input2, output| {
8282

timely/examples/bfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() {
4545

4646
// use the stream of edges
4747
graph.binary_notify(
48-
&stream,
48+
stream,
4949
Exchange::new(|x: &(u32, u32)| u64::from(x.0)),
5050
Exchange::new(|x: &(u32, u32)| u64::from(x.0)),
5151
"BFS",
@@ -130,7 +130,7 @@ fn main() {
130130
});
131131
}
132132
)
133-
.concat(&(0..1).map(|x| (x,x)).to_stream(scope))
133+
.concat((0..1).map(|x| (x,x)).to_stream(scope))
134134
.connect_loop(handle);
135135
});
136136
}).unwrap(); // asserts error-free execution;

timely/examples/hashjoin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() {
3232
let exchange2 = Exchange::new(|x: &(u64, u64)| x.0);
3333

3434
stream1
35-
.binary(&stream2, exchange1, exchange2, "HashJoin", |_capability, _info| {
35+
.binary(stream2, exchange1, exchange2, "HashJoin", |_capability, _info| {
3636

3737
let mut map1 = HashMap::<u64, Vec<u64>>::new();
3838
let mut map2 = HashMap::<u64, Vec<u64>>::new();

timely/examples/loopdemo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ fn main() {
2727

2828
let step =
2929
stream
30-
.concat(&loop_stream)
30+
.concat(loop_stream)
3131
.map(|x| if x % 2 == 0 { x / 2 } else { 3 * x + 1 })
3232
.filter(|x| x > &1);
33-
34-
step.connect_loop(loop_handle);
35-
step.probe_with(&mut probe);
33+
step
34+
.probe_with(&mut probe)
35+
.connect_loop(loop_handle);
3636
});
3737

3838
let ns_per_request = 1_000_000_000 / rate;

timely/examples/pagerank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
// bring edges and ranks together!
2525
let changes = edge_stream.binary_frontier(
26-
&rank_stream,
26+
rank_stream,
2727
Exchange::new(|x: &((usize, usize), i64)| (x.0).0 as u64),
2828
Exchange::new(|x: &(usize, i64)| x.0 as u64),
2929
"PageRank",

timely/examples/pingpong.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
(0 .. elements)
1515
.filter(move |&x| (x as usize) % peers == index)
1616
.to_stream(scope)
17-
.concat(&cycle)
17+
.concat(cycle)
1818
.exchange(|&x| x)
1919
.map_in_place(|x| *x += 1)
2020
.branch_when(move |t| t < &iterations).1

0 commit comments

Comments
 (0)