Class PartialFloatSum
java.lang.Object
dev.frostlake.functions.aggregate.PartialFloatSum
The double a FLOAT SUM or AVG answers, built from PARTIALS: each partial is a run of terms added with
Kahan compensation and read back with its last compensation applied
(
CompensatedSum.correctedValue()), and the partials are added in turn to a running compensated sum
that is read without it (CompensatedSum.value()).
The account's shapes are three uses of that one rule (all live-verified):
an aggregate, a whole-partition window one partial holding every row the corrected sum a running or sliding window frame every row a partial of its own the running sum a cumulative RANGE frame every peer group a partial corrected within a group
Over 0.3 then 0.7 squared the corrected sum is 0.57999999999999984901 and the running one
0.57999999999999996003: SUM(x * x) and SUM(x * x) OVER () answer the first,
SUM(x * x) OVER (ORDER BY i) answers the second on its last row, and OVER (ORDER BY k)
answers the first again on both rows when they share k.
-
Constructor Details
-
PartialFloatSum
public PartialFloatSum()
-
-
Method Details
-
add
public void add(double term) Add a term to the current partial.- Parameters:
term- the next value, in input order
-
endPartial
public void endPartial()Close the current partial: its corrected sum joins the running sum. A partial with no term adds nothing. -
result
public double result()The running sum of every partial, the current one closed first.- Returns:
- the sum, or
0.0before any term
-