paleolimbot commented on PR #1066:
URL: https://github.com/apache/sedona-db/pull/1066#issuecomment-5105917378

   Maybe a helper class in a separate file like
   
   ```rust
   struct StatsEvaluator<T> {
       values: Vec<T>,
       values_sorted: bool,
       count: i64,
       current_sum: Option<T>,
   }
   
   impl <T> for StatsEvaluator<T> {
        fn sum(&mut self) -> T {
            if let Some(cached_sum) = self.current_sum {
                cached_sum
            } else { // if floating point, sort values first, then compute sum 
and cache it }
        }
   }
   
   ```
   
   ...or something. That will let you benchmark and test it independently, 
perhaps against an existing library that has spent some time considering the 
corner cases of  (instead of going on hunches about what will or won't be 
faster or correct). This approach would also let you be lazy about computing 
stats (instead of computing all of them for every case and discarding all 
except one in the case of RS_ZonalStats).
   
   You could have one lazily constructed cached StatsEvaluator for each 
RasterDataType (for most cases there will only be one data type per batch so 
this won't explode scratch space).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to