@@ -9,10 +9,13 @@ use crate::ExchangeData;
99use crate :: order:: PartialOrder ;
1010
1111/// 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`.
1215pub trait Timestamp : Clone +Eq +PartialOrder +Debug +Send +Any +ExchangeData +Hash +Ord {
1316 /// A type summarizing action on a timestamp along a dataflow path.
1417 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.
1619 fn minimum ( ) -> Self ;
1720}
1821
@@ -28,14 +31,21 @@ pub trait PathSummary<T> : Clone+'static+Eq+PartialOrder+Debug+Default {
2831 /// in computation, uses this method and will drop messages with timestamps that when advanced
2932 /// result in `None`. Ideally, all other timestamp manipulation should behave similarly.
3033 ///
34+ /// This summary's partial order is expected to be compatible with the partial order of [T],
35+ /// in the sense that if `s1.less_equal(s2)`, then `s1.results_in(&t)` is less than or equal to
36+ /// `s2.results_in(&t)`.
37+ ///
38+ /// Note that `Self::default()` is expected to behave as an "empty" or "noop" summary, such that
39+ /// `Self::default().results_in(&t) == Some(t)`.
40+ ///
3141 /// # Examples
3242 /// ```
3343 /// use timely::progress::timestamp::PathSummary;
3444 ///
3545 /// let timestamp = 3;
3646 ///
3747 /// let summary1 = 5;
38- /// let summary2 = usize::max_value() - 2;
48+ /// let summary2 = usize::MAX - 2;
3949 ///
4050 /// assert_eq!(summary1.results_in(×tamp), Some(8));
4151 /// assert_eq!(summary2.results_in(×tamp), None);
@@ -49,14 +59,27 @@ pub trait PathSummary<T> : Clone+'static+Eq+PartialOrder+Debug+Default {
4959 /// important that this not be used casually, as this does not prevent the actual movement of
5060 /// data.
5161 ///
62+ /// Calling `results_in` on the composed summary should behave the same as though the two
63+ /// summaries were applied to the argument in order.
64+ ///
5265 /// # Examples
5366 /// ```
5467 /// use timely::progress::timestamp::PathSummary;
5568 ///
5669 /// let summary1 = 5;
57- /// let summary2 = usize::max_value() - 3;
70+ /// let summary2 = usize::MAX - 3;
5871 ///
5972 /// assert_eq!(summary1.followed_by(&summary2), None);
73+ ///
74+ /// let time = 10;
75+ /// let summary2 = 15;
76+ /// assert_eq!(
77+ /// // Applying the composed summary...
78+ /// summary1.followed_by(&summary2).and_then(|s| s.results_in(&time)),
79+ /// // ...has the same result as applying the two summaries in sequence.
80+ /// summary1.results_in(&time).and_then(|t| summary2.results_in(&t)),
81+ /// );
82+ ///
6083 /// ```
6184 fn followed_by ( & self , other : & Self ) -> Option < Self > ;
6285}
0 commit comments