Skip to content

Commit d4679be

Browse files
frankmcsherrypetrosagg
authored andcommitted
various code style changes
1 parent 8605f3b commit d4679be

File tree

15 files changed

+106
-73
lines changed

15 files changed

+106
-73
lines changed

src/algorithms/graphs/bfs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ where
4444
.concat(&nodes)
4545
.reduce(|_, s, t| t.push((s[0].0.clone(), 1)))
4646
})
47-
}
47+
}

src/operators/arrange/arrangement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ where
404404
let frontier = IntoIterator::into_iter([
405405
capability.as_ref().map(|c| c.time().clone()),
406406
input1.frontier().frontier().get(0).cloned(),
407-
]).flatten().min();
407+
]).filter_map(|t| t).min();
408408

409409
if let Some(frontier) = frontier {
410410
trace.as_mut().map(|t| t.set_logical_compaction(AntichainRef::new(&[frontier])));

src/operators/mod.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ impl<'a, V:'a, T, R> EditList<'a, V, T, R> where T: Ord+Clone, R: Semigroup {
4040
}
4141
/// Loads the contents of a cursor.
4242
fn load<C, L>(&mut self, cursor: &mut C, storage: &'a C::Storage, logic: L)
43-
where
44-
C: Cursor<Val=V, Time=T, R=R>,
45-
L: Fn(&T)->T,
46-
C::Key: Eq,
47-
V: Clone,
48-
{
43+
where V: Clone, C: Cursor<Val=V, Time=T, R=R>, C::Key: Eq, L: Fn(&T)->T {
4944
self.clear();
5045
while cursor.val_valid(storage) {
5146
cursor.map_times(storage, |time1, diff1| self.push(logic(time1), diff1.clone()));
@@ -108,10 +103,7 @@ impl<'storage, V: Ord+Clone+'storage, T: Lattice+Ord+Clone, R: Semigroup> ValueH
108103
self.buffer.clear();
109104
}
110105
fn load<C, L>(&mut self, cursor: &mut C, storage: &'storage C::Storage, logic: L)
111-
where C: Cursor<Val=V, Time=T, R=R>,
112-
C::Key: Eq,
113-
L: Fn(&T)->T,
114-
{
106+
where C: Cursor<Val=V, Time=T, R=R>, C::Key: Eq, L: Fn(&T)->T {
115107
self.edits.load(cursor, storage, logic);
116108
}
117109

@@ -125,9 +117,7 @@ impl<'storage, V: Ord+Clone+'storage, T: Lattice+Ord+Clone, R: Semigroup> ValueH
125117
key: &C::Key,
126118
logic: L
127119
) -> HistoryReplay<'storage, 'history, V, T, R>
128-
where C: Cursor<Val=V, Time=T, R=R>,
129-
C::Key: Eq,
130-
L: Fn(&T)->T,
120+
where C: Cursor<Val=V, Time=T, R=R>, C::Key: Eq, L: Fn(&T)->T
131121
{
132122
self.clear();
133123
cursor.seek_key(storage, key);

src/operators/reduce.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ where
670670
new_interesting: &mut Vec<T>) -> (usize, usize)
671671
where
672672
K: Eq+Clone,
673-
C1: Cursor<Key=K, Val=V1, Time=T, R=R1>,
674-
C2: Cursor<Key=K, Val=V2, Time=T, R=R2>,
675-
C3: Cursor<Key=K, Val=V1, Time=T, R=R1>,
673+
C1: Cursor<Key = K, Val = V1, Time = T, R = R1>,
674+
C2: Cursor<Key = K, Val = V2, Time = T, R = R2>,
675+
C3: Cursor<Key = K, Val = V1, Time = T, R = R1>,
676676
L: FnMut(&K, &[(&V1, R1)], &mut Vec<(V2, R2)>, &mut Vec<(V2, R2)>);
677677
}
678678

@@ -748,9 +748,9 @@ mod history_replay {
748748
new_interesting: &mut Vec<T>) -> (usize, usize)
749749
where
750750
K: Eq+Clone,
751-
C1: Cursor<Key=K, Val=V1, Time=T, R=R1>,
752-
C2: Cursor<Key=K, Val=V2, Time=T, R=R2>,
753-
C3: Cursor<Key=K, Val=V1, Time=T, R=R1>,
751+
C1: Cursor<Key = K, Val = V1, Time = T, R = R1>,
752+
C2: Cursor<Key = K, Val = V2, Time = T, R = R2>,
753+
C3: Cursor<Key = K, Val = V1, Time = T, R = R1>,
754754
L: FnMut(&K, &[(&V1, R1)], &mut Vec<(V2, R2)>, &mut Vec<(V2, R2)>)
755755
{
756756

src/trace/cursor/cursor_list.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ pub struct CursorList<C: Cursor> {
1313
min_val: Vec<usize>,
1414
}
1515

16-
impl<C: Cursor> CursorList<C>
17-
where C::Key: Ord,
18-
C::Val: Ord
19-
{
16+
impl<C: Cursor> CursorList<C> where C::Key: Ord, C::Val: Ord {
2017
/// Creates a new cursor list from pre-existing cursors.
2118
pub fn new(cursors: Vec<C>, storage: &[C::Storage]) -> Self {
2219

@@ -44,7 +41,7 @@ where C::Key: Ord,
4441
self.min_key.clear();
4542

4643
// Determine the index of the cursor with minimum key.
47-
let mut min_key_opt: Option<&C::Key> = None;
44+
let mut min_key_opt = None;
4845
for (index, cursor) in self.cursors.iter().enumerate() {
4946
let key = cursor.get_key(&storage[index]);
5047
if key.is_some() {
@@ -72,7 +69,7 @@ where C::Key: Ord,
7269
self.min_val.clear();
7370

7471
// Determine the index of the cursor with minimum value.
75-
let mut min_val: Option<&C::Val> = None;
72+
let mut min_val = None;
7673
for &index in self.min_key.iter() {
7774
let val = self.cursors[index].get_val(&storage[index]);
7875
if val.is_some() {
@@ -91,12 +88,13 @@ where C::Key: Ord,
9188
impl<C: Cursor> Cursor for CursorList<C>
9289
where
9390
C::Key: Ord,
94-
C::Val: Ord
91+
C::Val: Ord,
9592
{
9693
type Key = C::Key;
9794
type Val = C::Val;
9895
type Time = C::Time;
9996
type R = C::R;
97+
10098
type Storage = Vec<C::Storage>;
10199

102100
// validation methods

src/trace/cursor/cursor_pair.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ impl<K, V, T, R, C1, C2> Cursor for CursorPair<C1, C2>
1919
where
2020
K: Ord,
2121
V: Ord,
22-
C1: Cursor<Key=K, Val=V, Time=T, R=R>,
23-
C2: Cursor<Key=K, Val=V, Time=T, R=R>,
22+
C1: Cursor<Key = K, Val = V, Time = T, R = R>,
23+
C2: Cursor<Key = K, Val = V, Time = T, R = R>,
2424
{
2525
type Key = K;
2626
type Val = V;
2727
type Time = T;
2828
type R = R;
29+
2930
type Storage = (C1::Storage, C2::Storage);
3031

3132
// validation methods
@@ -135,4 +136,4 @@ where
135136
if self.key_order != Ordering::Greater { self.cursor1.rewind_vals(&storage.0); }
136137
if self.key_order != Ordering::Less { self.cursor2.rewind_vals(&storage.1); }
137138
}
138-
}
139+
}

src/trace/cursor/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub use self::cursor_list::CursorList;
1313

1414
/// A cursor for navigating ordered `(key, val, time, diff)` updates.
1515
pub trait Cursor {
16+
1617
/// Key by which updates are indexed.
1718
type Key;
1819
/// Values associated with keys.
@@ -21,6 +22,7 @@ pub trait Cursor {
2122
type Time;
2223
/// Associated update.
2324
type R;
25+
2426
/// Type the cursor addresses data in.
2527
type Storage;
2628

src/trace/implementations/ord.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ where
334334
type Val = V;
335335
type Time = T;
336336
type R = R;
337+
337338
type Storage = OrdValBatch<K, V, T, R, O>;
338339

339340
fn key<'a>(&self, storage: &'a Self::Storage) -> &'a K { &self.cursor.key(&storage.layer) }
@@ -643,6 +644,7 @@ where
643644
}
644645
}
645646

647+
646648
/// A cursor for navigating a single layer.
647649
#[derive(Debug)]
648650
pub struct OrdKeyCursor<K, T: Lattice+Ord+Clone, R: Semigroup, O=usize> {
@@ -658,13 +660,11 @@ where
658660
R: Semigroup,
659661
O: OrdOffset, <O as TryFrom<usize>>::Error: Debug, <O as TryInto<usize>>::Error: Debug
660662
{
661-
662663
type Key = K;
663664
type Val = ();
664665
type Time = T;
665666
type R = R;
666667

667-
668668
type Storage = OrdKeyBatch<K, T, R, O>;
669669

670670
fn key<'a>(&self, storage: &'a Self::Storage) -> &'a K { &self.cursor.key(&storage.layer) }

src/trace/mod.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub use self::description::Description;
4141
/// to update the contents of the trace. These methods are used to examine the contents, and to update the reader's
4242
/// capabilities (which may release restrictions on the mutations to the underlying trace and cause work to happen).
4343
pub trait TraceReader {
44+
4445
/// Key by which updates are indexed.
4546
type Key;
4647
/// Values associated with keys.
@@ -51,10 +52,10 @@ pub trait TraceReader {
5152
type R;
5253

5354
/// The type of an immutable collection of updates.
54-
type Batch: BatchReader<Key=Self::Key, Val=Self::Val, Time=Self::Time, R=Self::R>+Clone+'static;
55+
type Batch: BatchReader<Key = Self::Key, Val = Self::Val, Time = Self::Time, R = Self::R>+Clone+'static;
5556

5657
/// The type used to enumerate the collections contents.
57-
type Cursor: Cursor<Key=Self::Key, Val=Self::Val, Time=Self::Time, R=Self::R>;
58+
type Cursor: Cursor<Key = Self::Key, Val = Self::Val, Time = Self::Time, R = Self::R>;
5859

5960
/// Provides a cursor over updates contained in the trace.
6061
fn cursor(&mut self) -> (Self::Cursor, <Self::Cursor as Cursor>::Storage) {
@@ -195,7 +196,9 @@ pub trait TraceReader {
195196
///
196197
/// The trace must be constructable from, and navigable by the `Key`, `Val`, `Time` types, but does not need
197198
/// to return them.
198-
pub trait Trace: TraceReader {
199+
pub trait Trace : TraceReader
200+
where <Self as TraceReader>::Batch: Batch {
201+
199202
/// Allocates a new empty trace.
200203
fn new(
201204
info: ::timely::dataflow::operators::generic::OperatorInfo,
@@ -243,7 +246,7 @@ where
243246
type R;
244247

245248
/// The type used to enumerate the batch's contents.
246-
type Cursor: Cursor<Key=Self::Key, Val=Self::Val, Time=Self::Time, R=Self::R, Storage=Self>;
249+
type Cursor: Cursor<Key = Self::Key, Val = Self::Val, Time = Self::Time, R = Self::R, Storage=Self>;
247250
/// Acquires a cursor to the batch's contents.
248251
fn cursor(&self) -> Self::Cursor;
249252
/// The number of updates in the batch.
@@ -370,10 +373,12 @@ pub mod rc_blanket_impls {
370373
}
371374

372375
impl<B: BatchReader> Cursor for RcBatchCursor<B> {
376+
373377
type Key = B::Key;
374378
type Val = B::Val;
375379
type Time = B::Time;
376380
type R = B::R;
381+
377382
type Storage = Rc<B>;
378383

379384
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(storage) }
@@ -450,6 +455,7 @@ pub mod abomonated_blanket_impls {
450455
use super::{Batch, BatchReader, Batcher, Builder, Merger, Cursor, Description};
451456

452457
impl<B: BatchReader+Abomonation> BatchReader for Abomonated<B, Vec<u8>> {
458+
453459
type Key = B::Key;
454460
type Val = B::Val;
455461
type Time = B::Time;
@@ -482,10 +488,12 @@ pub mod abomonated_blanket_impls {
482488
}
483489

484490
impl<B: BatchReader+Abomonation> Cursor for AbomonatedBatchCursor<B> {
491+
485492
type Key = B::Key;
486493
type Val = B::Val;
487494
type Time = B::Time;
488495
type R = B::R;
496+
489497
type Storage = Abomonated<B, Vec<u8>>;
490498

491499
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(storage) }

src/trace/wrappers/enter.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ where
136136
BatchCursorEnter::new(self.batch.cursor())
137137
}
138138
fn len(&self) -> usize { self.batch.len() }
139-
fn description(&self) -> &Description<Self::Time> { &self.description }
139+
fn description(&self) -> &Description<TInner> { &self.description }
140140
}
141141

142142
impl<B, TInner> BatchEnter<B, TInner>
@@ -152,7 +152,7 @@ where
152152
let since: Vec<_> = batch.description().since().elements().iter().map(|x| TInner::to_inner(x.clone())).collect();
153153

154154
BatchEnter {
155-
batch,
155+
batch: batch,
156156
description: Description::new(Antichain::from(lower), Antichain::from(upper), Antichain::from(since))
157157
}
158158
}
@@ -168,20 +168,22 @@ impl<C: Cursor, TInner> CursorEnter<C, TInner> {
168168
fn new(cursor: C) -> Self {
169169
CursorEnter {
170170
phantom: ::std::marker::PhantomData,
171-
cursor,
171+
cursor: cursor,
172172
}
173173
}
174174
}
175175

176-
impl<C: Cursor, TInner> Cursor for CursorEnter<C, TInner>
176+
impl<C, TInner> Cursor for CursorEnter<C, TInner>
177177
where
178+
C: Cursor,
178179
C::Time: Timestamp,
179180
TInner: Refines<C::Time>+Lattice,
180181
{
181182
type Key = C::Key;
182183
type Val = C::Val;
183184
type Time = TInner;
184185
type R = C::R;
186+
185187
type Storage = C::Storage;
186188

187189
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(storage) }
@@ -207,6 +209,8 @@ where
207209
#[inline] fn rewind_vals(&mut self, storage: &Self::Storage) { self.cursor.rewind_vals(storage) }
208210
}
209211

212+
213+
210214
/// Wrapper to provide cursor to nested scope.
211215
pub struct BatchCursorEnter<B: BatchReader, TInner> {
212216
phantom: ::std::marker::PhantomData<TInner>,
@@ -222,7 +226,7 @@ impl<B: BatchReader, TInner> BatchCursorEnter<B, TInner> {
222226
}
223227
}
224228

225-
impl<B: BatchReader, TInner> Cursor for BatchCursorEnter<B, TInner>
229+
impl<TInner, B: BatchReader> Cursor for BatchCursorEnter<B, TInner>
226230
where
227231
B::Time: Timestamp,
228232
TInner: Refines<B::Time>+Lattice,
@@ -231,6 +235,7 @@ where
231235
type Val = B::Val;
232236
type Time = TInner;
233237
type R = B::R;
238+
234239
type Storage = BatchEnter<B, TInner>;
235240

236241
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(&storage.batch) }

src/trace/wrappers/enter_at.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ where
6262
type Time = TInner;
6363
type R = Tr::R;
6464

65-
type Batch = BatchEnter<Tr::Batch, TInner, F>;
66-
type Cursor = CursorEnter<Tr::Cursor, TInner, F>;
65+
type Batch = BatchEnter<Tr::Batch, TInner,F>;
66+
type Cursor = CursorEnter<Tr::Cursor, TInner,F>;
6767

6868
fn map_batches<F2: FnMut(&Self::Batch)>(&self, mut f: F2) {
6969
let logic = self.logic.clone();
@@ -120,7 +120,7 @@ where
120120
/// Makes a new trace wrapper
121121
pub fn make_from(trace: Tr, logic: F, prior: G) -> Self {
122122
TraceEnter {
123-
trace,
123+
trace: trace,
124124
stash1: Antichain::new(),
125125
stash2: Antichain::new(),
126126
logic,
@@ -207,6 +207,7 @@ where
207207
type Val = C::Val;
208208
type Time = TInner;
209209
type R = C::R;
210+
210211
type Storage = C::Storage;
211212

212213
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(storage) }
@@ -235,6 +236,8 @@ where
235236
#[inline] fn rewind_vals(&mut self, storage: &Self::Storage) { self.cursor.rewind_vals(storage) }
236237
}
237238

239+
240+
238241
/// Wrapper to provide cursor to nested scope.
239242
pub struct BatchCursorEnter<B: BatchReader, TInner, F> {
240243
phantom: ::std::marker::PhantomData<TInner>,
@@ -252,7 +255,7 @@ impl<B: BatchReader, TInner, F> BatchCursorEnter<B, TInner, F> {
252255
}
253256
}
254257

255-
impl<B: BatchReader, TInner, F> Cursor for BatchCursorEnter<B, TInner, F>
258+
impl<TInner, B: BatchReader, F> Cursor for BatchCursorEnter<B, TInner, F>
256259
where
257260
B::Time: Timestamp,
258261
TInner: Refines<B::Time>+Lattice,
@@ -262,6 +265,7 @@ where
262265
type Val = B::Val;
263266
type Time = TInner;
264267
type R = B::R;
268+
265269
type Storage = BatchEnter<B, TInner, F>;
266270

267271
#[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(&storage.batch) }

0 commit comments

Comments
 (0)