@@ -37,8 +37,15 @@ use crate::hashable::Hashable;
3737/// parameter is the type of data in your collection, for example `String`, or `(u32, Vec<Option<()>>)`.
3838/// The `R` parameter represents the types of changes that the data undergo, and is most commonly (and
3939/// defaults to) `isize`, representing changes to the occurrence count of each record.
40+ pub type Collection < G , D , R = isize > = CollectionCore < G , Vec < ( D , <G as ScopeParent >:: Timestamp , R ) > > ;
41+
42+ /// A collection represented by a stream of abstract containers.
43+ ///
44+ /// The containers purport to reperesent changes to a collection, and they must implement various traits
45+ /// in order to expose some of this functionality (e.g. negation, timestamp manipulation). Other actions
46+ /// on the containers, and streams of containers, are left to the container implementor to describe.
4047#[ derive( Clone ) ]
41- pub struct Collection < G : Scope , D , R = isize , C = Vec < ( D , < G as ScopeParent > :: Timestamp , R ) > > {
48+ pub struct CollectionCore < G : Scope , C > {
4249 /// The underlying timely dataflow stream.
4350 ///
4451 /// This field is exposed to support direct timely dataflow manipulation when required, but it is
@@ -48,11 +55,9 @@ pub struct Collection<G: Scope, D, R = isize, C = Vec<(D, <G as ScopeParent>::Ti
4855 /// the timely-dataflow sense. If this invariant is not upheld, differential operators may behave
4956 /// unexpectedly.
5057 pub inner : timely:: dataflow:: StreamCore < G , C > ,
51- /// Phantom data for unreferenced `D` and `R` types.
52- phantom : std:: marker:: PhantomData < ( D , R ) > ,
5358}
5459
55- impl < G : Scope , D , R , C > Collection < G , D , R , C > {
60+ impl < G : Scope , C > CollectionCore < G , C > {
5661 /// Creates a new Collection from a timely dataflow stream.
5762 ///
5863 /// This method seems to be rarely used, with the `as_collection` method on streams being a more
@@ -62,11 +67,9 @@ impl<G: Scope, D, R, C> Collection<G, D, R, C> {
6267 ///
6368 /// This stream should satisfy the timestamp invariant as documented on [Collection]; this
6469 /// method does not check it.
65- pub fn new ( stream : StreamCore < G , C > ) -> Collection < G , D , R , C > {
66- Collection { inner : stream, phantom : std:: marker:: PhantomData }
67- }
70+ pub fn new ( stream : StreamCore < G , C > ) -> Self { Self { inner : stream } }
6871}
69- impl < G : Scope , D , R , C : Container > Collection < G , D , R , C > {
72+ impl < G : Scope , C : Container > CollectionCore < G , C > {
7073 /// Creates a new collection accumulating the contents of the two collections.
7174 ///
7275 /// Despite the name, differential dataflow collections are unordered. This method is so named because the
@@ -128,7 +131,7 @@ impl<G: Scope, D, R, C: Container> Collection<G, D, R, C> {
128131 ///
129132 /// This method is a specialization of `enter` to the case where the nested scope is a region.
130133 /// It removes the need for an operator that adjusts the timestamp.
131- pub fn enter_region < ' a > ( & self , child : & Child < ' a , G , <G as ScopeParent >:: Timestamp > ) -> Collection < Child < ' a , G , <G as ScopeParent >:: Timestamp > , D , R , C > {
134+ pub fn enter_region < ' a > ( & self , child : & Child < ' a , G , <G as ScopeParent >:: Timestamp > ) -> CollectionCore < Child < ' a , G , <G as ScopeParent >:: Timestamp > , C > {
132135 self . inner
133136 . enter ( child)
134137 . as_collection ( )
@@ -204,7 +207,7 @@ impl<G: Scope, D, R, C: Container> Collection<G, D, R, C> {
204207 /// .assert_eq(&evens);
205208 /// });
206209 /// ```
207- pub fn negate ( & self ) -> Collection < G , D , R , C > where C : containers:: Negate {
210+ pub fn negate ( & self ) -> Self where C : containers:: Negate {
208211 use timely:: dataflow:: channels:: pact:: Pipeline ;
209212 self . inner
210213 . unary ( Pipeline , "Negate" , move |_, _| move |input, output| {
@@ -233,7 +236,7 @@ impl<G: Scope, D, R, C: Container> Collection<G, D, R, C> {
233236 /// data.assert_eq(&result);
234237 /// });
235238 /// ```
236- pub fn enter < ' a , T > ( & self , child : & Child < ' a , G , T > ) -> Collection < Child < ' a , G , T > , D , R , <C as containers:: Enter < <G as ScopeParent >:: Timestamp , T > >:: InnerContainer >
239+ pub fn enter < ' a , T > ( & self , child : & Child < ' a , G , T > ) -> CollectionCore < Child < ' a , G , T > , <C as containers:: Enter < <G as ScopeParent >:: Timestamp , T > >:: InnerContainer >
237240 where
238241 C : containers:: Enter < <G as ScopeParent >:: Timestamp , T , InnerContainer : Container > ,
239242 T : Refines < <G as ScopeParent >:: Timestamp > ,
@@ -594,7 +597,7 @@ use timely::dataflow::scopes::ScopeParent;
594597use timely:: progress:: timestamp:: Refines ;
595598
596599/// Methods requiring a nested scope.
597- impl < ' a , G : Scope , T : Timestamp , D : Clone + ' static , R : Clone + ' static , C : Container > Collection < Child < ' a , G , T > , D , R , C >
600+ impl < ' a , G : Scope , T : Timestamp , C : Container > CollectionCore < Child < ' a , G , T > , C >
598601where
599602 C : containers:: Leave < T , G :: Timestamp , OuterContainer : Container > ,
600603 T : Refines < <G as ScopeParent >:: Timestamp > ,
@@ -619,7 +622,7 @@ where
619622 /// data.assert_eq(&result);
620623 /// });
621624 /// ```
622- pub fn leave ( & self ) -> Collection < G , D , R , <C as containers:: Leave < T , G :: Timestamp > >:: OuterContainer > {
625+ pub fn leave ( & self ) -> CollectionCore < G , <C as containers:: Leave < T , G :: Timestamp > >:: OuterContainer > {
623626 use timely:: dataflow:: channels:: pact:: Pipeline ;
624627 self . inner
625628 . leave ( )
@@ -631,13 +634,13 @@ where
631634}
632635
633636/// Methods requiring a region as the scope.
634- impl < G : Scope , D , R , C : Container +Data > Collection < Child < ' _ , G , G :: Timestamp > , D , R , C >
637+ impl < G : Scope , C : Container +Data > CollectionCore < Child < ' _ , G , G :: Timestamp > , C >
635638{
636639 /// Returns the value of a Collection from a nested region to its containing scope.
637640 ///
638641 /// This method is a specialization of `leave` to the case that of a nested region.
639642 /// It removes the need for an operator that adjusts the timestamp.
640- pub fn leave_region ( & self ) -> Collection < G , D , R , C > {
643+ pub fn leave_region ( & self ) -> CollectionCore < G , C > {
641644 self . inner
642645 . leave ( )
643646 . as_collection ( )
@@ -682,18 +685,18 @@ impl<G: Scope<Timestamp: Data>, D: Clone+'static, R: Abelian+'static> Collection
682685}
683686
684687/// Conversion to a differential dataflow Collection.
685- pub trait AsCollection < G : Scope , D , R , C > {
688+ pub trait AsCollection < G : Scope , C > {
686689 /// Converts the type to a differential dataflow collection.
687- fn as_collection ( & self ) -> Collection < G , D , R , C > ;
690+ fn as_collection ( & self ) -> CollectionCore < G , C > ;
688691}
689692
690- impl < G : Scope , D , R , C : Clone > AsCollection < G , D , R , C > for StreamCore < G , C > {
693+ impl < G : Scope , C : Clone > AsCollection < G , C > for StreamCore < G , C > {
691694 /// Converts the type to a differential dataflow collection.
692695 ///
693696 /// By calling this method, you guarantee that the timestamp invariant (as documented on
694697 /// [Collection]) is upheld. This method will not check it.
695- fn as_collection ( & self ) -> Collection < G , D , R , C > {
696- Collection :: < G , D , R , C > :: new ( self . clone ( ) )
698+ fn as_collection ( & self ) -> CollectionCore < G , C > {
699+ CollectionCore :: < G , C > :: new ( self . clone ( ) )
697700 }
698701}
699702
@@ -718,13 +721,11 @@ impl<G: Scope, D, R, C: Clone> AsCollection<G, D, R, C> for StreamCore<G, C> {
718721/// .assert_eq(&data);
719722/// });
720723/// ```
721- pub fn concatenate < G , D , R , C , I > ( scope : & mut G , iterator : I ) -> Collection < G , D , R , C >
724+ pub fn concatenate < G , C , I > ( scope : & mut G , iterator : I ) -> CollectionCore < G , C >
722725where
723726 G : Scope ,
724- D : Data ,
725- R : Semigroup + ' static ,
726727 C : Container ,
727- I : IntoIterator < Item =Collection < G , D , R , C > > ,
728+ I : IntoIterator < Item =CollectionCore < G , C > > ,
728729{
729730 scope
730731 . concatenate ( iterator. into_iter ( ) . map ( |x| x. inner ) )
0 commit comments