Class VarPAggregator<V extends Number>
- All Implemented Interfaces:
Externalizable
,Serializable
,Aggregator<V,
Double, VarPAggregator<V>>
- Direct Known Subclasses:
StdDevPAggregator
,VarSAggregator
This class implements the SQL Standard VAR_POP() aggregator, computing a population's variance. It uses the IBM formula described here:
sum(xi2)/n - m2 where n is the number of items in the population m is the population average x1 ... xn are the items in the population
The IBM formula can be computed without buffering up an arbitrarily long list of items. The IBM formula is algebraically equivalent to the textbook formula for population variance:
sum( (xi - m)2 )/n
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
private static final long
protected VarPAggregator.Sums
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accumulate
(V value) Accumulate the next scalar valueprotected Double
void
init()
Initialize the Aggregatorvoid
merge
(VarPAggregator<V> otherAggregator) For merging another partial result into this Aggregator.void
Return the result scalar valuevoid
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
sums
-
count
protected int count
-
-
Constructor Details
-
VarPAggregator
public VarPAggregator()
-
-
Method Details
-
init
public void init()Description copied from interface:Aggregator
Initialize the Aggregator- Specified by:
init
in interfaceAggregator<V extends Number,
Double, VarPAggregator<V extends Number>>
-
accumulate
Description copied from interface:Aggregator
Accumulate the next scalar value- Specified by:
accumulate
in interfaceAggregator<V extends Number,
Double, VarPAggregator<V extends Number>>
-
merge
Description copied from interface:Aggregator
For merging another partial result into this Aggregator. This lets the SQL interpreter divide the incoming rows into subsets, aggregating each subset in isolation, and then merging the partial results together. This method can be called when performing a grouped aggregation with a large number of groups. While processing such a query, Derby may write intermediate grouped results to disk. The intermediate results may be retrieved and merged with later results if Derby encounters later rows which belong to groups whose intermediate results have been written to disk. This situation can occur with a query like the following:
select a, mode( b ) from mode_inputs group by a order by a
- Specified by:
merge
in interfaceAggregator<V extends Number,
Double, VarPAggregator<V extends Number>>
-
computeVar
-
terminate
Description copied from interface:Aggregator
Return the result scalar value- Specified by:
terminate
in interfaceAggregator<V extends Number,
Double, VarPAggregator<V extends Number>>
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-