@@ -119,18 +119,9 @@ impl<V: AggregateFnVTable> DynAccumulator for Accumulator<V> {
119119 batch. dtype( )
120120 ) ;
121121
122- // Stat::Sum stores a finalized scalar rather than a partial. Give Sum's vtable the first
123- // chance to consume that cache before dispatching an encoding kernel.
124- let checked_cached_sum = Stat :: from_aggregate_fn ( & self . aggregate_fn ) == Some ( Stat :: Sum )
125- && batch. statistics ( ) . get ( Stat :: Sum ) . is_exact ( ) ;
126- if checked_cached_sum && self . vtable . try_accumulate ( & mut self . partial , batch, ctx) ? {
127- return Ok ( ( ) ) ;
128- }
129-
130- // 0. Cached stats bridge: consume an exact partial from the aggregate's Stat slot before
131- // kernel dispatch or decode. Sum is handled above because its cache stores a result.
122+ // 0. Legacy stats bridge: if this aggregate is still cached under a legacy Stat slot,
123+ // consume that exact stat before kernel dispatch or decode.
132124 if let Some ( stat) = Stat :: from_aggregate_fn ( & self . aggregate_fn )
133- && stat != Stat :: Sum
134125 && let Precision :: Exact ( partial) = batch. statistics ( ) . get ( stat)
135126 {
136127 let partial = if partial. dtype ( ) == & self . partial_dtype {
@@ -176,7 +167,7 @@ impl<V: AggregateFnVTable> DynAccumulator for Accumulator<V> {
176167 }
177168
178169 // 2. Allow the vtable to short-circuit on the raw array before decompression.
179- if !checked_cached_sum && self . vtable . try_accumulate ( & mut self . partial , batch, ctx) ? {
170+ if self . vtable . try_accumulate ( & mut self . partial , batch, ctx) ? {
180171 return Ok ( ( ) ) ;
181172 }
182173
@@ -289,7 +280,6 @@ mod tests {
289280 use crate :: aggregate_fn:: combined:: PairOptions ;
290281 use crate :: aggregate_fn:: fns:: mean:: Mean ;
291282 use crate :: aggregate_fn:: fns:: sum:: Sum ;
292- use crate :: aggregate_fn:: fns:: sum:: SumAggregateOpts ;
293283 use crate :: aggregate_fn:: kernels:: DynAggregateKernel ;
294284 use crate :: aggregate_fn:: session:: AggregateFnSession ;
295285 use crate :: array:: VTable ;
@@ -298,10 +288,7 @@ mod tests {
298288 use crate :: dtype:: DType ;
299289 use crate :: dtype:: Nullability ;
300290 use crate :: dtype:: PType ;
301- use crate :: expr:: stats:: Precision ;
302- use crate :: expr:: stats:: Stat ;
303291 use crate :: scalar:: Scalar ;
304- use crate :: scalar:: ScalarValue ;
305292
306293 /// Mean partial sentinel `{sum: 42.0, count: 1}` — distinguishable from the
307294 /// natural fan-out result `{sum: 7.0, count: 1}` that `Combined::try_accumulate`
@@ -333,7 +320,7 @@ mod tests {
333320 }
334321 }
335322
336- /// Sum partial sentinel `{sum: 42.0, is_overflow: false, is_empty: false} ` — distinguishable from the natural Sum of
323+ /// Sum partial sentinel `42.0` — distinguishable from the natural Sum of
337324 /// `dict_of_seven()` which is `7.0`.
338325 #[ derive( Debug ) ]
339326 struct SentinelSumPartialKernel ;
@@ -344,7 +331,7 @@ mod tests {
344331 _batch : & ArrayRef ,
345332 _ctx : & mut ExecutionCtx ,
346333 ) -> VortexResult < Option < Scalar > > {
347- Ok ( Some ( sum_partial ( 42.0 ) ) )
334+ Ok ( Some ( Scalar :: primitive ( 42.0f64 , Nullability :: Nullable ) ) )
348335 }
349336 }
350337
@@ -363,7 +350,7 @@ mod tests {
363350 Accumulator :: try_new (
364351 Mean :: combined ( ) ,
365352 PairOptions (
366- SumAggregateOpts :: default ( ) ,
353+ NumericalAggregateOpts :: default ( ) ,
367354 NumericalAggregateOpts :: default ( ) ,
368355 ) ,
369356 dtype,
@@ -372,24 +359,11 @@ mod tests {
372359
373360 fn sentinel_partial ( ) -> Scalar {
374361 let acc = mean_f64_accumulator ( ) . expect ( "build accumulator" ) ;
375- let sum = sum_partial ( 42.0 ) ;
362+ let sum = Scalar :: primitive ( 42.0f64 , Nullability :: Nullable ) ;
376363 let count = Scalar :: primitive ( 1u64 , Nullability :: NonNullable ) ;
377364 Scalar :: struct_ ( acc. partial_dtype , vec ! [ sum, count] )
378365 }
379366
380- fn sum_partial ( value : f64 ) -> Scalar {
381- let dtype = DType :: Primitive ( PType :: F64 , Nullability :: NonNullable ) ;
382- let acc = Accumulator :: try_new ( Sum , SumAggregateOpts :: default ( ) , dtype) . expect ( "sum" ) ;
383- Scalar :: struct_ (
384- acc. partial_dtype ,
385- vec ! [
386- Scalar :: primitive( value, Nullability :: NonNullable ) ,
387- Scalar :: bool ( false , Nullability :: NonNullable ) ,
388- Scalar :: bool ( false , Nullability :: NonNullable ) ,
389- ] ,
390- )
391- }
392-
393367 /// Kernel registered for `(Dict, Combined<Mean>)` fires in preference to
394368 /// `Combined::try_accumulate`'s fan-out path — proves the dispatch reorder.
395369 #[ test]
@@ -407,13 +381,7 @@ mod tests {
407381
408382 let s = partial. as_struct ( ) ;
409383 assert_eq ! (
410- s. field( "sum" )
411- . unwrap( )
412- . as_struct( )
413- . field( "sum" )
414- . unwrap( )
415- . as_primitive( )
416- . as_:: <f64 >( ) ,
384+ s. field( "sum" ) . unwrap( ) . as_primitive( ) . as_:: <f64 >( ) ,
417385 Some ( 42.0 )
418386 ) ;
419387 assert_eq ! (
@@ -440,13 +408,7 @@ mod tests {
440408
441409 let s = partial. as_struct ( ) ;
442410 assert_eq ! (
443- s. field( "sum" )
444- . unwrap( )
445- . as_struct( )
446- . field( "sum" )
447- . unwrap( )
448- . as_primitive( )
449- . as_:: <f64 >( ) ,
411+ s. field( "sum" ) . unwrap( ) . as_primitive( ) . as_:: <f64 >( ) ,
450412 Some ( 7.0 )
451413 ) ;
452414 assert_eq ! (
@@ -477,13 +439,7 @@ mod tests {
477439 // via `Combined<Mean>`'s fan-out. `Count`'s native `try_accumulate` reads the
478440 // batch's valid_count, so count is the real 1.
479441 assert_eq ! (
480- s. field( "sum" )
481- . unwrap( )
482- . as_struct( )
483- . field( "sum" )
484- . unwrap( )
485- . as_primitive( )
486- . as_:: <f64 >( ) ,
442+ s. field( "sum" ) . unwrap( ) . as_primitive( ) . as_:: <f64 >( ) ,
487443 Some ( 42.0 )
488444 ) ;
489445 assert_eq ! (
@@ -492,26 +448,4 @@ mod tests {
492448 ) ;
493449 Ok ( ( ) )
494450 }
495-
496- #[ test]
497- fn cached_sum_precedes_encoding_kernel ( ) -> VortexResult < ( ) > {
498- static KERNEL : SentinelSumPartialKernel = SentinelSumPartialKernel ;
499- let session = fresh_session ( ) ;
500- session
501- . get :: < AggregateFnSession > ( )
502- . register_aggregate_kernel ( Dict . id ( ) , Some ( Sum . id ( ) ) , & KERNEL ) ;
503- let mut ctx = session. create_execution_ctx ( ) ;
504-
505- let batch = dict_of_seven ( ) ;
506- batch
507- . statistics ( )
508- . set ( Stat :: Sum , Precision :: Exact ( ScalarValue :: from ( 11.0f64 ) ) ) ;
509-
510- let dtype = DType :: Primitive ( PType :: F64 , Nullability :: NonNullable ) ;
511- let mut acc = Accumulator :: try_new ( Sum , SumAggregateOpts :: default ( ) , dtype) ?;
512- acc. accumulate ( & batch, & mut ctx) ?;
513-
514- assert_eq ! ( acc. finish( ) ?. as_primitive( ) . as_:: <f64 >( ) , Some ( 11.0 ) ) ;
515- Ok ( ( ) )
516- }
517451}
0 commit comments