Skip to content

Commit 30ac63d

Browse files
Introduce trait constraints; simplify elsewhere (#445)
1 parent cd3914e commit 30ac63d

File tree

27 files changed

+132
-371
lines changed

27 files changed

+132
-371
lines changed

dogsdogsdogs/src/operators/count.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ pub fn count<G, Tr, R, F, P>(
1919
index: usize,
2020
) -> Collection<G, (P, usize, usize), R>
2121
where
22-
G: Scope,
23-
G::Timestamp: Lattice,
24-
Tr: TraceReader<ValOwned=(), Time=G::Timestamp, Diff=isize>+Clone+'static,
22+
G: Scope<Timestamp=Tr::Time>,
23+
Tr: TraceReader<ValOwned=(), Diff=isize>+Clone+'static,
2524
Tr::KeyOwned: Hashable + Default,
2625
R: Monoid+Multiply<Output = R>+ExchangeData,
2726
F: Fn(&P)->Tr::KeyOwned+Clone+'static,

dogsdogsdogs/src/operators/half_join.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ pub fn half_join<G, V, R, Tr, FF, CF, DOut, S>(
7676
mut output_func: S,
7777
) -> Collection<G, (DOut, G::Timestamp), <R as Mul<Tr::Diff>>::Output>
7878
where
79-
G: Scope,
80-
G::Timestamp: Lattice,
81-
Tr::KeyOwned: Ord + Hashable + ExchangeData,
79+
G: Scope<Timestamp = Tr::Time>,
80+
Tr::KeyOwned: Hashable + ExchangeData,
8281
V: ExchangeData,
8382
R: ExchangeData + Monoid,
84-
Tr: TraceReader<Time=G::Timestamp>+Clone+'static,
85-
Tr::Diff: Semigroup,
83+
Tr: TraceReader+Clone+'static,
8684
R: Mul<Tr::Diff>,
8785
<R as Mul<Tr::Diff>>::Output: Semigroup,
8886
FF: Fn(&G::Timestamp) -> G::Timestamp + 'static,
@@ -131,13 +129,11 @@ pub fn half_join_internal_unsafe<G, V, R, Tr, FF, CF, DOut, ROut, Y, I, S>(
131129
mut output_func: S,
132130
) -> Collection<G, DOut, ROut>
133131
where
134-
G: Scope,
135-
G::Timestamp: Lattice,
136-
Tr::KeyOwned: Ord + Hashable + ExchangeData,
132+
G: Scope<Timestamp = Tr::Time>,
133+
Tr::KeyOwned: Hashable + ExchangeData,
137134
V: ExchangeData,
138135
R: ExchangeData + Monoid,
139-
Tr: TraceReader<Time=G::Timestamp>+Clone+'static,
140-
Tr::Diff: Semigroup,
136+
Tr: TraceReader+Clone+'static,
141137
FF: Fn(&G::Timestamp) -> G::Timestamp + 'static,
142138
CF: Fn(&G::Timestamp, &G::Timestamp) -> bool + 'static,
143139
DOut: Clone+'static,

dogsdogsdogs/src/operators/lookup_map.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ pub fn lookup_map<G, D, R, Tr, F, DOut, ROut, S>(
2727
supplied_key2: Tr::KeyOwned,
2828
) -> Collection<G, DOut, ROut>
2929
where
30-
G: Scope,
31-
G::Timestamp: Lattice,
32-
Tr: TraceReader<Time=G::Timestamp>+Clone+'static,
30+
G: Scope<Timestamp=Tr::Time>,
31+
Tr: TraceReader+Clone+'static,
3332
Tr::KeyOwned: Hashable,
3433
Tr::Diff: Monoid+ExchangeData,
3534
F: FnMut(&D, &mut Tr::KeyOwned)+Clone+'static,

dogsdogsdogs/src/operators/propose.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ pub fn propose<G, Tr, F, P>(
2121
key_selector: F,
2222
) -> Collection<G, (P, Tr::ValOwned), Tr::Diff>
2323
where
24-
G: Scope,
25-
G::Timestamp: Lattice,
26-
Tr: TraceReader<Time=G::Timestamp>+Clone+'static,
24+
G: Scope<Timestamp=Tr::Time>,
25+
Tr: TraceReader+Clone+'static,
2726
Tr::KeyOwned: Hashable + Default,
2827
Tr::Diff: Monoid+Multiply<Output = Tr::Diff>+ExchangeData,
2928
F: Fn(&P)->Tr::KeyOwned+Clone+'static,
@@ -51,9 +50,8 @@ pub fn propose_distinct<G, Tr, F, P>(
5150
key_selector: F,
5251
) -> Collection<G, (P, Tr::ValOwned), Tr::Diff>
5352
where
54-
G: Scope,
55-
G::Timestamp: Lattice,
56-
Tr: TraceReader<Time=G::Timestamp>+Clone+'static,
53+
G: Scope<Timestamp=Tr::Time>,
54+
Tr: TraceReader+Clone+'static,
5755
Tr::KeyOwned: Hashable + Default,
5856
Tr::Diff: Monoid+Multiply<Output = Tr::Diff>+ExchangeData,
5957
F: Fn(&P)->Tr::KeyOwned+Clone+'static,

dogsdogsdogs/src/operators/validate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ pub fn validate<G, K, V, Tr, F, P>(
1919
key_selector: F,
2020
) -> Collection<G, (P, V), Tr::Diff>
2121
where
22-
G: Scope,
23-
G::Timestamp: Lattice,
24-
Tr: TraceReader<KeyOwned=(K,V), ValOwned=(), Time=G::Timestamp>+Clone+'static,
22+
G: Scope<Timestamp=Tr::Time>,
23+
Tr: TraceReader<KeyOwned=(K,V), ValOwned=()>+Clone+'static,
2524
K: Ord+Hash+Clone+Default,
2625
V: ExchangeData+Hash+Default,
2726
Tr::Diff: Monoid+Multiply<Output = Tr::Diff>+ExchangeData,

examples/cursors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ fn main() {
132132
fn dump_cursor<Tr>(round: u32, index: usize, trace: &mut Tr)
133133
where
134134
Tr: TraceReader,
135-
Tr::KeyOwned: Debug + Clone,
136-
Tr::ValOwned: Debug + Clone,
137-
Tr::Time: Debug + Clone,
138-
Tr::Diff: Debug + Clone,
135+
Tr::KeyOwned: Debug,
136+
Tr::ValOwned: Debug,
137+
Tr::Time: Debug,
138+
Tr::Diff: Debug,
139139
{
140140
let (mut cursor, storage) = trace.cursor();
141141
for ((k, v), diffs) in cursor.to_vec(&storage).iter() {

src/algorithms/graphs/bfs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ use crate::operators::arrange::Arranged;
2626
/// Returns pairs (node, dist) indicating distance of each node from a root.
2727
pub fn bfs_arranged<G, N, Tr>(edges: &Arranged<G, Tr>, roots: &Collection<G, N>) -> Collection<G, (N, u32)>
2828
where
29-
G: Scope,
30-
G::Timestamp: Lattice+Ord,
29+
G: Scope<Timestamp=Tr::Time>,
3130
N: ExchangeData+Hash,
32-
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Time=G::Timestamp, Diff=isize>+Clone+'static,
31+
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Diff=isize>+Clone+'static,
3332
{
3433
// initialize roots as reaching themselves at distance 0
3534
let nodes = roots.map(|x| (x, 0));

src/algorithms/graphs/bijkstra.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ pub fn bidijkstra_arranged<G, N, Tr>(
4242
goals: &Collection<G, (N,N)>
4343
) -> Collection<G, ((N,N), u32)>
4444
where
45-
G: Scope,
46-
G::Timestamp: Lattice+Ord,
45+
G: Scope<Timestamp=Tr::Time>,
4746
N: ExchangeData+Hash,
48-
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Time=G::Timestamp, Diff=isize>+Clone+'static,
47+
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Diff=isize>+Clone+'static,
4948
{
5049
forward
5150
.stream

src/algorithms/graphs/propagate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ use crate::operators::arrange::arrangement::Arranged;
5656
/// of `logic should be a number in the interval [0,64],
5757
pub fn propagate_core<G, N, L, Tr, F, R>(edges: &Arranged<G,Tr>, nodes: &Collection<G,(N,L),R>, logic: F) -> Collection<G,(N,L),R>
5858
where
59-
G: Scope,
60-
G::Timestamp: Lattice+Ord,
59+
G: Scope<Timestamp=Tr::Time>,
6160
N: ExchangeData+Hash,
6261
R: ExchangeData+Abelian,
6362
R: Multiply<R, Output=R>,
6463
R: From<i8>,
6564
L: ExchangeData,
66-
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Time=G::Timestamp, Diff=R>+Clone+'static,
65+
Tr: for<'a> TraceReader<Key<'a>=&'a N, Val<'a>=&'a N, Diff=R>+Clone+'static,
6766
F: Fn(&L)->u64+Clone+'static,
6867
{
6968
// Morally the code performs the following iterative computation. However, in the interest of a simplified

src/operators/arrange/agent.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use timely::progress::Timestamp;
1010
use timely::progress::{Antichain, frontier::AntichainRef};
1111
use timely::dataflow::operators::CapabilitySet;
1212

13-
use crate::lattice::Lattice;
1413
use crate::trace::{Trace, TraceReader, Batch, BatchReader};
1514
use crate::trace::wrappers::rc::TraceBox;
1615

@@ -29,7 +28,6 @@ use crate::trace::wrappers::frontier::{TraceFrontier, BatchFrontier};
2928
pub struct TraceAgent<Tr>
3029
where
3130
Tr: TraceReader,
32-
Tr::Time: Lattice+Ord+Clone+'static,
3331
{
3432
trace: Rc<RefCell<TraceBox<Tr>>>,
3533
queues: Weak<RefCell<Vec<TraceAgentQueueWriter<Tr>>>>,
@@ -44,7 +42,6 @@ where
4442
impl<Tr> TraceReader for TraceAgent<Tr>
4543
where
4644
Tr: TraceReader,
47-
Tr::Time: Lattice+Ord+Clone+'static,
4845
{
4946
type Key<'a> = Tr::Key<'a>;
5047
type KeyOwned = Tr::KeyOwned;
@@ -85,11 +82,7 @@ where
8582
fn map_batches<F: FnMut(&Self::Batch)>(&self, f: F) { self.trace.borrow().trace.map_batches(f) }
8683
}
8784

88-
impl<Tr> TraceAgent<Tr>
89-
where
90-
Tr: TraceReader,
91-
Tr::Time: Timestamp+Lattice,
92-
{
85+
impl<Tr: TraceReader> TraceAgent<Tr> {
9386
/// Creates a new agent from a trace reader.
9487
pub fn new(trace: Tr, operator: OperatorInfo, logging: Option<crate::logging::Logger>) -> (Self, TraceWriter<Tr>)
9588
where
@@ -177,7 +170,6 @@ where
177170
impl<Tr> TraceAgent<Tr>
178171
where
179172
Tr: TraceReader+'static,
180-
Tr::Time: Lattice+Ord+Clone+'static,
181173
{
182174
/// Copies an existing collection into the supplied scope.
183175
///
@@ -233,7 +225,6 @@ where
233225
pub fn import<G>(&mut self, scope: &G) -> Arranged<G, TraceAgent<Tr>>
234226
where
235227
G: Scope<Timestamp=Tr::Time>,
236-
Tr::Time: Timestamp,
237228
{
238229
self.import_named(scope, "ArrangedSource")
239230
}
@@ -242,7 +233,6 @@ where
242233
pub fn import_named<G>(&mut self, scope: &G, name: &str) -> Arranged<G, TraceAgent<Tr>>
243234
where
244235
G: Scope<Timestamp=Tr::Time>,
245-
Tr::Time: Timestamp,
246236
{
247237
// Drop ShutdownButton and return only the arrangement.
248238
self.import_core(scope, name).0
@@ -300,7 +290,6 @@ where
300290
pub fn import_core<G>(&mut self, scope: &G, name: &str) -> (Arranged<G, TraceAgent<Tr>>, ShutdownButton<CapabilitySet<Tr::Time>>)
301291
where
302292
G: Scope<Timestamp=Tr::Time>,
303-
Tr::Time: Timestamp,
304293
{
305294
let trace = self.clone();
306295

@@ -418,7 +407,6 @@ where
418407
pub fn import_frontier<G>(&mut self, scope: &G, name: &str) -> (Arranged<G, TraceFrontier<TraceAgent<Tr>>>, ShutdownButton<CapabilitySet<Tr::Time>>)
419408
where
420409
G: Scope<Timestamp=Tr::Time>,
421-
Tr::Time: Timestamp+ Lattice+Ord+Clone+'static,
422410
Tr: TraceReader,
423411
{
424412
// This frontier describes our only guarantee on the compaction frontier.
@@ -437,7 +425,6 @@ where
437425
pub fn import_frontier_core<G>(&mut self, scope: &G, name: &str, since: Antichain<Tr::Time>, until: Antichain<Tr::Time>) -> (Arranged<G, TraceFrontier<TraceAgent<Tr>>>, ShutdownButton<CapabilitySet<Tr::Time>>)
438426
where
439427
G: Scope<Timestamp=Tr::Time>,
440-
Tr::Time: Timestamp+ Lattice+Ord+Clone+'static,
441428
Tr: TraceReader,
442429
{
443430
let trace = self.clone();
@@ -541,7 +528,6 @@ impl<T> Drop for ShutdownDeadmans<T> {
541528
impl<Tr> Clone for TraceAgent<Tr>
542529
where
543530
Tr: TraceReader,
544-
Tr::Time: Lattice+Ord+Clone+'static,
545531
{
546532
fn clone(&self) -> Self {
547533

@@ -571,7 +557,6 @@ where
571557
impl<Tr> Drop for TraceAgent<Tr>
572558
where
573559
Tr: TraceReader,
574-
Tr::Time: Lattice+Ord+Clone+'static,
575560
{
576561
fn drop(&mut self) {
577562

0 commit comments

Comments
 (0)