@@ -9,10 +9,13 @@ use crate::communication::Data;
9
9
use crate :: order:: PartialOrder ;
10
10
11
11
/// A composite trait for types that serve as timestamps in timely dataflow.
12
+ ///
13
+ /// By implementing this trait, you promise that the type's [PartialOrder] implementation
14
+ /// is compatible with [Ord], such that if `a.less_equal(b)` then `a <= b`.
12
15
pub trait Timestamp : Clone +Eq +PartialOrder +Debug +Send +Any +Data +Hash +Ord {
13
16
/// A type summarizing action on a timestamp along a dataflow path.
14
17
type Summary : PathSummary < Self > + ' static ;
15
- /// A minimum value suitable as a default.
18
+ /// A unique minimum value in our partial order, suitable as a default.
16
19
fn minimum ( ) -> Self ;
17
20
}
18
21
@@ -28,14 +31,17 @@ pub trait PathSummary<T> : Clone+'static+Eq+PartialOrder+Debug+Default {
28
31
/// in computation, uses this method and will drop messages with timestamps that when advanced
29
32
/// result in `None`. Ideally, all other timestamp manipulation should behave similarly.
30
33
///
34
+ /// Note that `Self::default()` is expected to behave as an "empty" or "noop" summary, such that
35
+ /// `Self::default().results_in(&t) == Some(t)`.
36
+ ///
31
37
/// # Examples
32
38
/// ```
33
39
/// use timely::progress::timestamp::PathSummary;
34
40
///
35
41
/// let timestamp = 3;
36
42
///
37
43
/// let summary1 = 5;
38
- /// let summary2 = usize::max_value() - 2;
44
+ /// let summary2 = usize::MAX - 2;
39
45
///
40
46
/// assert_eq!(summary1.results_in(×tamp), Some(8));
41
47
/// assert_eq!(summary2.results_in(×tamp), None);
@@ -45,18 +51,31 @@ pub trait PathSummary<T> : Clone+'static+Eq+PartialOrder+Debug+Default {
45
51
///
46
52
/// It is possible that the two composed paths result in an invalid summary, for example when
47
53
/// integer additions overflow. If it is correct that all timestamps moved along these paths
48
- /// would also result in overflow and be discarded, `followed_by` can return `None. It is very
54
+ /// would also result in overflow and be discarded, `followed_by` can return `None` . It is very
49
55
/// important that this not be used casually, as this does not prevent the actual movement of
50
56
/// data.
51
57
///
58
+ /// Calling `results_in` on the composed summary should behave the same as though the two
59
+ /// summaries were applied to the argument in order.
60
+ ///
52
61
/// # Examples
53
62
/// ```
54
63
/// use timely::progress::timestamp::PathSummary;
55
64
///
56
65
/// let summary1 = 5;
57
- /// let summary2 = usize::max_value() - 3;
66
+ /// let summary2 = usize::MAX - 3;
58
67
///
59
68
/// assert_eq!(summary1.followed_by(&summary2), None);
69
+ ///
70
+ /// let time = 10;
71
+ /// let summary2 = 15;
72
+ /// assert_eq!(
73
+ /// // Applying the composed summary...
74
+ /// summary1.followed_by(&summary2).and_then(|s| s.results_in(&time)),
75
+ /// // ...has the same result as applying the two summaries in sequence.
76
+ /// summary1.results_in(&time).and_then(|t| summary2.results_in(&t)),
77
+ /// );
78
+ ///
60
79
/// ```
61
80
fn followed_by ( & self , other : & Self ) -> Option < Self > ;
62
81
}
0 commit comments