11use std:: { fmt, mem, ops} ;
22
3- use crate :: accumulator:: accumulated_map:: {
4- AccumulatedMap , AtomicInputAccumulatedValues , InputAccumulatedValues ,
3+ #[ cfg( feature = "accumulator" ) ]
4+ use crate :: accumulator:: {
5+ accumulated_map:: { AccumulatedMap , AtomicInputAccumulatedValues , InputAccumulatedValues } ,
6+ Accumulator ,
57} ;
68use crate :: cycle:: { CycleHeads , IterationCount } ;
79use crate :: durability:: Durability ;
@@ -11,7 +13,7 @@ use crate::runtime::Stamp;
1113use crate :: sync:: atomic:: AtomicBool ;
1214use crate :: tracked_struct:: { Disambiguator , DisambiguatorMap , IdentityHash , IdentityMap } ;
1315use crate :: zalsa_local:: { QueryEdge , QueryOrigin , QueryRevisions , QueryRevisionsExtra } ;
14- use crate :: { Accumulator , IngredientIndex , Revision } ;
16+ use crate :: Revision ;
1517
1618#[ derive( Debug ) ]
1719pub ( crate ) struct ActiveQuery {
@@ -51,10 +53,12 @@ pub(crate) struct ActiveQuery {
5153
5254 /// Stores the values accumulated to the given ingredient.
5355 /// The type of accumulated value is erased but known to the ingredient.
56+ #[ cfg( feature = "accumulator" ) ]
5457 accumulated : AccumulatedMap ,
5558
5659 /// [`InputAccumulatedValues::Empty`] if any input read during the query's execution
5760 /// has any accumulated values.
61+ #[ cfg( feature = "accumulator" ) ]
5862 accumulated_inputs : InputAccumulatedValues ,
5963
6064 /// Provisional cycle results that this query depends on.
@@ -84,18 +88,21 @@ impl ActiveQuery {
8488 input : DatabaseKeyIndex ,
8589 durability : Durability ,
8690 changed_at : Revision ,
87- has_accumulated : bool ,
88- accumulated_inputs : & AtomicInputAccumulatedValues ,
8991 cycle_heads : & CycleHeads ,
92+ #[ cfg( feature = "accumulator" ) ] has_accumulated : bool ,
93+ #[ cfg( feature = "accumulator" ) ] accumulated_inputs : & AtomicInputAccumulatedValues ,
9094 ) {
9195 self . durability = self . durability . min ( durability) ;
9296 self . changed_at = self . changed_at . max ( changed_at) ;
9397 self . input_outputs . insert ( QueryEdge :: input ( input) ) ;
94- self . accumulated_inputs = self . accumulated_inputs . or_else ( || match has_accumulated {
95- true => InputAccumulatedValues :: Any ,
96- false => accumulated_inputs. load ( ) ,
97- } ) ;
9898 self . cycle_heads . extend ( cycle_heads) ;
99+ #[ cfg( feature = "accumulator" ) ]
100+ {
101+ self . accumulated_inputs = self . accumulated_inputs . or_else ( || match has_accumulated {
102+ true => InputAccumulatedValues :: Any ,
103+ false => accumulated_inputs. load ( ) ,
104+ } ) ;
105+ }
99106 }
100107
101108 pub ( super ) fn add_read_simple (
@@ -121,7 +128,8 @@ impl ActiveQuery {
121128 self . changed_at = self . changed_at . max ( revision) ;
122129 }
123130
124- pub ( super ) fn accumulate ( & mut self , index : IngredientIndex , value : impl Accumulator ) {
131+ #[ cfg( feature = "accumulator" ) ]
132+ pub ( super ) fn accumulate ( & mut self , index : crate :: IngredientIndex , value : impl Accumulator ) {
125133 self . accumulated . accumulate ( index, value) ;
126134 }
127135
@@ -169,10 +177,12 @@ impl ActiveQuery {
169177 untracked_read : false ,
170178 disambiguator_map : Default :: default ( ) ,
171179 tracked_struct_ids : Default :: default ( ) ,
172- accumulated : Default :: default ( ) ,
173- accumulated_inputs : Default :: default ( ) ,
174180 cycle_heads : Default :: default ( ) ,
175181 iteration_count,
182+ #[ cfg( feature = "accumulator" ) ]
183+ accumulated : Default :: default ( ) ,
184+ #[ cfg( feature = "accumulator" ) ]
185+ accumulated_inputs : Default :: default ( ) ,
176186 }
177187 }
178188
@@ -185,10 +195,12 @@ impl ActiveQuery {
185195 untracked_read,
186196 ref mut disambiguator_map,
187197 ref mut tracked_struct_ids,
188- ref mut accumulated,
189- accumulated_inputs,
190198 ref mut cycle_heads,
191199 iteration_count,
200+ #[ cfg( feature = "accumulator" ) ]
201+ ref mut accumulated,
202+ #[ cfg ( feature = "accumulator" ) ]
203+ accumulated_inputs,
192204 } = self ;
193205
194206 let origin = if untracked_read {
@@ -198,19 +210,22 @@ impl ActiveQuery {
198210 } ;
199211 disambiguator_map. clear ( ) ;
200212
213+ #[ cfg( feature = "accumulator" ) ]
214+ let accumulated_inputs = AtomicInputAccumulatedValues :: new ( accumulated_inputs) ;
201215 let verified_final = cycle_heads. is_empty ( ) ;
202216 let extra = QueryRevisionsExtra :: new (
217+ #[ cfg( feature = "accumulator" ) ]
203218 mem:: take ( accumulated) ,
204219 mem:: take ( tracked_struct_ids) ,
205220 mem:: take ( cycle_heads) ,
206221 iteration_count,
207222 ) ;
208- let accumulated_inputs = AtomicInputAccumulatedValues :: new ( accumulated_inputs) ;
209223
210224 QueryRevisions {
211225 changed_at,
212226 durability,
213227 origin,
228+ #[ cfg( feature = "accumulator" ) ]
214229 accumulated_inputs,
215230 verified_final : AtomicBool :: new ( verified_final) ,
216231 extra,
@@ -226,17 +241,20 @@ impl ActiveQuery {
226241 untracked_read : _,
227242 disambiguator_map,
228243 tracked_struct_ids,
229- accumulated,
230- accumulated_inputs : _,
231244 cycle_heads,
232245 iteration_count,
246+ #[ cfg( feature = "accumulator" ) ]
247+ accumulated,
248+ #[ cfg ( feature = "accumulator" ) ]
249+ accumulated_inputs: _,
233250 } = self ;
234251 input_outputs. clear ( ) ;
235252 disambiguator_map. clear ( ) ;
236253 tracked_struct_ids. clear ( ) ;
237- accumulated. clear ( ) ;
238254 * cycle_heads = Default :: default ( ) ;
239255 * iteration_count = IterationCount :: initial ( ) ;
256+ #[ cfg( feature = "accumulator" ) ]
257+ accumulated. clear ( ) ;
240258 }
241259
242260 fn reset_for (
@@ -252,16 +270,17 @@ impl ActiveQuery {
252270 untracked_read,
253271 disambiguator_map,
254272 tracked_struct_ids,
255- accumulated,
256- accumulated_inputs,
257273 cycle_heads,
258274 iteration_count,
275+ #[ cfg( feature = "accumulator" ) ]
276+ accumulated,
277+ #[ cfg ( feature = "accumulator" ) ]
278+ accumulated_inputs,
259279 } = self ;
260280 * database_key_index = new_database_key_index;
261281 * durability = Durability :: MAX ;
262282 * changed_at = Revision :: start ( ) ;
263283 * untracked_read = false ;
264- * accumulated_inputs = Default :: default ( ) ;
265284 * iteration_count = new_iteration_count;
266285 debug_assert ! (
267286 input_outputs. is_empty( ) ,
@@ -279,10 +298,14 @@ impl ActiveQuery {
279298 cycle_heads. is_empty( ) ,
280299 "`ActiveQuery::clear` or `ActiveQuery::into_revisions` should've been called"
281300 ) ;
282- debug_assert ! (
283- accumulated. is_empty( ) ,
284- "`ActiveQuery::clear` or `ActiveQuery::into_revisions` should've been called"
285- ) ;
301+ #[ cfg( feature = "accumulator" ) ]
302+ {
303+ * accumulated_inputs = Default :: default ( ) ;
304+ debug_assert ! (
305+ accumulated. is_empty( ) ,
306+ "`ActiveQuery::clear` or `ActiveQuery::into_revisions` should've been called"
307+ ) ;
308+ }
286309 }
287310}
288311
0 commit comments