@@ -16,8 +16,6 @@ use timely::progress::{Antichain, frontier::AntichainRef};
16
16
use timely:: progress:: Timestamp ;
17
17
18
18
use crate :: logging:: Logger ;
19
- use crate :: difference:: Semigroup ;
20
- use crate :: lattice:: Lattice ;
21
19
pub use self :: cursor:: Cursor ;
22
20
pub use self :: description:: Description ;
23
21
@@ -46,34 +44,48 @@ pub type ExertionLogic = std::sync::Arc<dyn for<'a> Fn(&'a [(usize, usize, usize
46
44
/// This is a restricted interface to the more general `Trace` trait, which extends this trait with further methods
47
45
/// to update the contents of the trace. These methods are used to examine the contents, and to update the reader's
48
46
/// capabilities (which may release restrictions on the mutations to the underlying trace and cause work to happen).
49
- pub trait TraceReader {
50
-
51
- /// Key by which updates are indexed.
52
- type Key < ' a > : Copy + Clone + Ord ;
53
- /// Values associated with keys.
54
- type Val < ' a > : Copy + Clone ;
55
- /// Timestamps associated with updates
56
- type Time : Timestamp + Lattice + Ord + Clone ;
57
- /// Borrowed form of timestamp.
58
- type TimeGat < ' a > : Copy ;
59
- /// Owned form of update difference.
60
- type Diff : Semigroup + ' static ;
61
- /// Borrowed form of update difference.
62
- type DiffGat < ' a > : Copy ;
63
-
64
- /// An owned copy of a reference to a time.
65
- #[ inline( always) ] fn owned_time ( time : Self :: TimeGat < ' _ > ) -> Self :: Time { Self :: Cursor :: owned_time ( time) }
66
- /// An owned copy of a reference to a diff.
67
- #[ inline( always) ] fn owned_diff ( diff : Self :: DiffGat < ' _ > ) -> Self :: Diff { Self :: Cursor :: owned_diff ( diff) }
47
+ pub trait TraceReader : LayoutExt {
68
48
69
49
/// The type of an immutable collection of updates.
70
- type Batch : for < ' a > BatchReader < Key < ' a > = Self :: Key < ' a > , Val < ' a > = Self :: Val < ' a > , Time = Self :: Time , TimeGat < ' a > = Self :: TimeGat < ' a > , Diff = Self :: Diff , DiffGat < ' a > = Self :: DiffGat < ' a > > +Clone +' static ;
50
+ type Batch :
51
+ ' static +
52
+ Clone +
53
+ BatchReader +
54
+ LaidOut < Layout = Self :: Layout > +
55
+ for < ' a > LayoutExt <
56
+ Key < ' a > = Self :: Key < ' a > ,
57
+ Val < ' a > = Self :: Val < ' a > ,
58
+ Time = Self :: Time ,
59
+ TimeGat < ' a > = Self :: TimeGat < ' a > ,
60
+ Diff = Self :: Diff ,
61
+ DiffGat < ' a > = Self :: DiffGat < ' a > ,
62
+ KeyContainer = Self :: KeyContainer ,
63
+ ValContainer = Self :: ValContainer ,
64
+ TimeContainer = Self :: TimeContainer ,
65
+ DiffContainer = Self :: DiffContainer ,
66
+ > ;
67
+
71
68
72
69
/// Storage type for `Self::Cursor`. Likely related to `Self::Batch`.
73
70
type Storage ;
74
71
75
72
/// The type used to enumerate the collections contents.
76
- type Cursor : for < ' a > Cursor < Storage =Self :: Storage , Key < ' a > = Self :: Key < ' a > , Val < ' a > = Self :: Val < ' a > , Time = Self :: Time , TimeGat < ' a > = Self :: TimeGat < ' a > , Diff = Self :: Diff , DiffGat < ' a > = Self :: DiffGat < ' a > > ;
73
+ type Cursor :
74
+ Cursor < Storage =Self :: Storage > +
75
+ LaidOut < Layout = Self :: Layout > +
76
+ for < ' a > LayoutExt <
77
+ Key < ' a > = Self :: Key < ' a > ,
78
+ Val < ' a > = Self :: Val < ' a > ,
79
+ Time = Self :: Time ,
80
+ TimeGat < ' a > = Self :: TimeGat < ' a > ,
81
+ Diff = Self :: Diff ,
82
+ DiffGat < ' a > = Self :: DiffGat < ' a > ,
83
+ KeyContainer = Self :: KeyContainer ,
84
+ ValContainer = Self :: ValContainer ,
85
+ TimeContainer = Self :: TimeContainer ,
86
+ DiffContainer = Self :: DiffContainer ,
87
+ > ;
88
+
77
89
78
90
/// Provides a cursor over updates contained in the trace.
79
91
fn cursor ( & mut self ) -> ( Self :: Cursor , Self :: Storage ) {
@@ -221,34 +233,34 @@ pub trait Trace : TraceReader<Batch: Batch> {
221
233
fn close ( & mut self ) ;
222
234
}
223
235
236
+ use crate :: trace:: implementations:: LaidOut ;
237
+
224
238
/// A batch of updates whose contents may be read.
225
239
///
226
240
/// This is a restricted interface to batches of updates, which support the reading of the batch's contents,
227
241
/// but do not expose ways to construct the batches. This trait is appropriate for views of the batch, and is
228
242
/// especially useful for views derived from other sources in ways that prevent the construction of batches
229
243
/// from the type of data in the view (for example, filtered views, or views with extended time coordinates).
230
- pub trait BatchReader : Sized {
231
- /// Key by which updates are indexed.
232
- type Key < ' a > : Copy + Clone + Ord ;
233
- /// Values associated with keys.
234
- type Val < ' a > : Copy + Clone ;
235
- /// Timestamps associated with updates
236
- type Time : Timestamp + Lattice + Ord + Clone ;
237
- /// Borrowed form of timestamp.
238
- type TimeGat < ' a > : Copy ;
239
- /// Owned form of update difference.
240
- type Diff : Semigroup + ' static ;
241
- /// Borrowed form of update difference.
242
- type DiffGat < ' a > : Copy ;
243
-
244
- /// An owned copy of a reference to a time.
245
- #[ inline( always) ] fn owned_time ( time : Self :: TimeGat < ' _ > ) -> Self :: Time { Self :: Cursor :: owned_time ( time) }
246
- /// An owned copy of a reference to a diff.
247
- #[ inline( always) ] fn owned_diff ( diff : Self :: DiffGat < ' _ > ) -> Self :: Diff { Self :: Cursor :: owned_diff ( diff) }
244
+ pub trait BatchReader : LayoutExt + Sized {
248
245
249
246
/// The type used to enumerate the batch's contents.
250
- type Cursor : for < ' a > Cursor < Storage =Self , Key < ' a > = Self :: Key < ' a > , Val < ' a > = Self :: Val < ' a > , Time = Self :: Time , TimeGat < ' a > = Self :: TimeGat < ' a > , Diff = Self :: Diff , DiffGat < ' a > = Self :: DiffGat < ' a > > ;
251
- /// Acquires a cursor to the batch's contents.
247
+ type Cursor :
248
+ Cursor < Storage =Self > +
249
+ LaidOut < Layout = Self :: Layout > +
250
+ for < ' a > LayoutExt <
251
+ Key < ' a > = Self :: Key < ' a > ,
252
+ Val < ' a > = Self :: Val < ' a > ,
253
+ Time = Self :: Time ,
254
+ TimeGat < ' a > = Self :: TimeGat < ' a > ,
255
+ Diff = Self :: Diff ,
256
+ DiffGat < ' a > = Self :: DiffGat < ' a > ,
257
+ KeyContainer = Self :: KeyContainer ,
258
+ ValContainer = Self :: ValContainer ,
259
+ TimeContainer = Self :: TimeContainer ,
260
+ DiffContainer = Self :: DiffContainer ,
261
+ > ;
262
+
263
+ /// Acquires a cursor to the batch's contents.
252
264
fn cursor ( & self ) -> Self :: Cursor ;
253
265
/// The number of updates in the batch.
254
266
fn len ( & self ) -> usize ;
@@ -359,13 +371,11 @@ pub mod rc_blanket_impls {
359
371
use timely:: progress:: { Antichain , frontier:: AntichainRef } ;
360
372
use super :: { Batch , BatchReader , Builder , Merger , Cursor , Description } ;
361
373
374
+ impl < B : BatchReader > LaidOut for Rc < B > {
375
+ type Layout = B :: Layout ;
376
+ }
377
+
362
378
impl < B : BatchReader > BatchReader for Rc < B > {
363
- type Key < ' a > = B :: Key < ' a > ;
364
- type Val < ' a > = B :: Val < ' a > ;
365
- type Time = B :: Time ;
366
- type TimeGat < ' a > = B :: TimeGat < ' a > ;
367
- type Diff = B :: Diff ;
368
- type DiffGat < ' a > = B :: DiffGat < ' a > ;
369
379
370
380
/// The type used to enumerate the batch's contents.
371
381
type Cursor = RcBatchCursor < B :: Cursor > ;
0 commit comments