@@ -110,7 +110,7 @@ impl<G: Scope<Timestamp: Lattice>, D: Ord+Data+Debug, R: Semigroup+'static> Iter
110110 // wrapped by `variable`, but it also results in substantially more
111111 // diffs produced; `result` is post-consolidation, and means fewer
112112 // records are yielded out of the loop.
113- let ( variable, collection) = SemigroupVariable :: new ( subgraph, Product :: new ( Default :: default ( ) , 1 ) ) ;
113+ let ( variable, collection) = Variable :: new ( subgraph, Product :: new ( Default :: default ( ) , 1 ) ) ;
114114 let result = logic ( subgraph. clone ( ) , collection) ;
115115 variable. set ( result. clone ( ) ) ;
116116 result. leave ( )
@@ -166,7 +166,7 @@ pub type VecVariable<G, D, R> = Variable<G, Vec<(D, <G as ScopeParent>::Timestam
166166impl < G , C : Container > Variable < G , C >
167167where
168168 G : Scope < Timestamp : Lattice > ,
169- C : crate :: collection:: containers:: Negate + crate :: collection :: containers :: ResultsIn < <G :: Timestamp as Timestamp >:: Summary > ,
169+ C : crate :: collection:: containers:: ResultsIn < <G :: Timestamp as Timestamp >:: Summary > ,
170170{
171171 /// Creates a new initially empty `Variable`.
172172 ///
@@ -179,10 +179,10 @@ where
179179 }
180180
181181 /// Creates a new `Variable` from a supplied `source` stream.
182- pub fn new_from ( source : Collection < G , C > , step : <G :: Timestamp as Timestamp >:: Summary ) -> ( Self , Collection < G , C > ) where C : Clone {
182+ pub fn new_from ( source : Collection < G , C > , step : <G :: Timestamp as Timestamp >:: Summary ) -> ( Self , Collection < G , C > ) where C : Clone + crate :: collection :: containers :: Negate {
183183 let ( feedback, updates) = source. inner . scope ( ) . feedback ( step. clone ( ) ) ;
184184 let collection = Collection :: < G , C > :: new ( updates) . concat ( source. clone ( ) ) ;
185- ( Variable { feedback, source : Some ( source) , step } , collection)
185+ ( Variable { feedback, source : Some ( source. negate ( ) ) , step } , collection)
186186 }
187187
188188 /// Set the definition of the `Variable` to a collection.
@@ -191,61 +191,10 @@ where
191191 /// which may be recursively defined in terms of the variable itself.
192192 pub fn set ( mut self , mut result : Collection < G , C > ) {
193193 if let Some ( source) = self . source . take ( ) {
194- result = result. concat ( source. negate ( ) ) ;
194+ result = result. concat ( source) ;
195195 }
196- self . set_concat ( result)
197- }
198-
199- /// Set the definition of the `Variable` to a collection concatenated to `self`.
200- ///
201- /// This method is a specialization of `set` which has the effect of concatenating
202- /// `result` and `self` before calling `set`. This method avoids some dataflow
203- /// complexity related to retracting the initial input, and will do less work in
204- /// that case.
205- ///
206- /// This behavior can also be achieved by using `new` to create an empty initial
207- /// collection, and then using `self.set(self.concat(result))`.
208- pub fn set_concat ( self , result : Collection < G , C > ) {
209- let step = self . step ;
210- result
211- . results_in ( step)
212- . inner
213- . connect_loop ( self . feedback ) ;
214- }
215- }
216-
217- /// A recursively defined collection that only "grows".
218- ///
219- /// `SemigroupVariable` is a weakening of `Variable` to allow difference types
220- /// that do not implement `Abelian` and only implement `Semigroup`. This means
221- /// that it can be used in settings where the difference type does not support
222- /// negation.
223- pub struct SemigroupVariable < G , C >
224- where
225- G : Scope < Timestamp : Lattice > ,
226- C : Container ,
227- {
228- feedback : Handle < G , C > ,
229- step : <G :: Timestamp as Timestamp >:: Summary ,
230- }
231-
232- impl < G , C : Container > SemigroupVariable < G , C >
233- where
234- G : Scope < Timestamp : Lattice > ,
235- C : crate :: collection:: containers:: ResultsIn < <G :: Timestamp as Timestamp >:: Summary > ,
236- {
237- /// Creates a new initially empty `SemigroupVariable`.
238- pub fn new ( scope : & mut G , step : <G :: Timestamp as Timestamp >:: Summary ) -> ( Self , Collection < G , C > ) {
239- let ( feedback, updates) = scope. feedback ( step. clone ( ) ) ;
240- let collection = Collection :: < G , C > :: new ( updates) ;
241- ( SemigroupVariable { feedback, step } , collection)
242- }
243-
244- /// Adds a new source of data to `self`.
245- pub fn set ( self , result : Collection < G , C > ) {
246- let step = self . step ;
247196 result
248- . results_in ( step)
197+ . results_in ( self . step )
249198 . inner
250199 . connect_loop ( self . feedback ) ;
251200 }
0 commit comments