- java.lang.Object
-
- com.pervasive.datarush.operators.group.Aggregation
-
public final class Aggregation extends Object
A representation of an aggregation on a specific field in a record. To be used withGroup.Users should only use the
#Aggregation(AggregatorFactory, String)constructor for custom-coded aggregation operators. Otherwise, they should use the static factory methods this class provides, such as#sum(String)and#max(String).
-
-
Constructor Summary
Constructors Constructor Description Aggregation(AggregatorFactory aggregatorFactory, ScalarValuedFunction sourceFunction)Constructs anAggregationfor a specified record field using specified arguments.Aggregation(AggregatorFactory aggregatorFactory, String sourceField)Constructs anAggregationfor a specified record field using specified arguments.Aggregation(AggregatorFactory aggregatorFactory, List<ScalarValuedFunction> sourceFunctions)Constructs anAggregationfor a specified record field using specified arguments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Aggregationas(String label)Creates an identical aggregation whose output field name will be the specified label.static Aggregationavg(ScalarValuedFunction input)Create an average value aggregation for the given input.static Aggregationavg(String input)Create an average value aggregation for the given input.static Aggregationcorr(ScalarValuedFunction input1, ScalarValuedFunction input2)Create a correlation aggregation for the given inputs.static Aggregationcorr(String input1, String input2)Create a correlation aggregation for the given inputs.static Aggregationcount()Create a count aggregation for all rows within a group.static Aggregationcount(ScalarValuedFunction input)Create a value count aggregation for the given input.static Aggregationcount(String input)Create a value count aggregation for the given input.static Aggregationcovar(ScalarValuedFunction input1, ScalarValuedFunction input2)Create a covariance aggregation for the given inputs.static Aggregationcovar(ScalarValuedFunction input1, ScalarValuedFunction input2, boolean sample)Create a covariance aggregation for the given inputs.static Aggregationcovar(String input1, String input2)Create a covariance aggregation for the given inputs.static Aggregationcovar(String input1, String input2, boolean sample)Create a covariance aggregation for the given inputs.Aggregationdistinct(boolean distinct)Creates an identical aggregation whose distinct flag is set to the specified value.booleanequals(Object o)static AggregationgeoAvg(ScalarValuedFunction input)Create a geometric average value aggregation for the given input.static AggregationgeoAvg(String input)Create a geometric average value aggregation for the given input.AggregatorFactorygetAggregatorFactory()Returns the aggregator factory for this aggregation.StringgetOutputName()Returns the output name for this aggregation.List<ScalarValuedFunction>getSourceFunctions()Returns the source functions of this aggregation.static AggregationharmAvg(ScalarValuedFunction input)Create an harmonic average value aggregation for the given input.static AggregationharmAvg(String input)Create an harmonic average value aggregation for the given input.inthashCode()booleanisDistinct()Returns whether to compute the aggregation based on the distinct values of the given field(s).static Aggregationkurtosis(ScalarValuedFunction input)Create a kurtosis aggregation for the given input.static Aggregationkurtosis(ScalarValuedFunction input, boolean sample)Create a kurtosis aggregation for the given input.static Aggregationkurtosis(String input)Create a kurtosis aggregation for the given input.static Aggregationkurtosis(String input, boolean sample)Create a kurtosis aggregation for the given input.static Aggregationmax(ScalarValuedFunction input)Create a maximum value aggregation for the given input.static Aggregationmax(String input)Create a maximum value aggregation for the given input.static Aggregationmin(ScalarValuedFunction input)Create a minimum value aggregation for the given input.static Aggregationmin(String input)Create a minimum value aggregation for the given input.static Aggregationmoment(ScalarValuedFunction input, int k)Create a central moment aggregation for the given input.static Aggregationmoment(String input, int k)Create a central moment aggregation for the given input.static Aggregationskewness(ScalarValuedFunction input)Create a skewness aggregation for the given input.static Aggregationskewness(ScalarValuedFunction input, boolean sample)Create a skewness aggregation for the given input.static Aggregationskewness(String input)Create a skewness aggregation for the given input.static Aggregationskewness(String input, boolean sample)Create a skewness aggregation for the given input.static Aggregationstddev(ScalarValuedFunction input)Create a standard deviation aggregation for the given input.static Aggregationstddev(ScalarValuedFunction input, boolean sample)Create a standard deviation aggregation for the given input.static Aggregationstddev(String input)Create a standard deviation aggregation for the given input.static Aggregationstddev(String input, boolean sample)Create a standard deviation aggregation for the given input.static Aggregationsum(ScalarValuedFunction input)Create a value summation aggregation for the given input.static Aggregationsum(String input)Create a value summation aggregation for the given input.static AggregationsumSquares(ScalarValuedFunction input)Create a sum-squares aggregation for the given input.static AggregationsumSquares(String input)Create a sum-squares aggregation for the given input.StringtoString()voidvalidateInputType(RecordTokenType inputType)Validate the input types to this aggregation.static Aggregationvar(ScalarValuedFunction input)Create a variance aggregation for the given input.static Aggregationvar(ScalarValuedFunction input, boolean sample)Create a variance aggregation for the given input.static Aggregationvar(String input)Create a variance aggregation for the given input.static Aggregationvar(String input, boolean sample)Create a variance aggregation for the given input.
-
-
-
Constructor Detail
-
Aggregation
public Aggregation(AggregatorFactory aggregatorFactory, String sourceField)
Constructs anAggregationfor a specified record field using specified arguments.- Parameters:
aggregatorFactory- the factory for constructing the desired aggregatorsourceField- the field to aggregate
-
Aggregation
public Aggregation(AggregatorFactory aggregatorFactory, ScalarValuedFunction sourceFunction)
Constructs anAggregationfor a specified record field using specified arguments.- Parameters:
aggregatorFactory- the factory for constructing the desired aggregatorsourceFunction- the function to aggregate
-
Aggregation
public Aggregation(AggregatorFactory aggregatorFactory, List<ScalarValuedFunction> sourceFunctions)
Constructs anAggregationfor a specified record field using specified arguments.- Parameters:
aggregatorFactory- the factory for constructing the desired aggregatorsourceFields- the fields to aggregate
-
-
Method Detail
-
as
public Aggregation as(String label)
Creates an identical aggregation whose output field name will be the specified label. This is analogous to theASkeyword in SQL. The supplied name must be unique among all fields in the result or an error will be raised during graph composition.Use this method to explictly specify the name of the result. For example, to sum the prices in the group and label the result "revenue":
Aggegation.sum("salePrice").as("revenue")- Parameters:
label- the name to use for the output field- Returns:
- an aggregation using the specified name for the result field
-
distinct
public Aggregation distinct(boolean distinct)
Creates an identical aggregation whose distinct flag is set to the specified value.- Parameters:
distinct- whether to compute distinct aggregations- Returns:
- an aggregation whose distinct flag is set accordinging
-
isDistinct
public boolean isDistinct()
Returns whether to compute the aggregation based on the distinct values of the given field(s).- Returns:
- whether to compute the aggregation based on the distinct values of the given field(s).
-
getSourceFunctions
public List<ScalarValuedFunction> getSourceFunctions()
Returns the source functions of this aggregation.- Returns:
- the source functions of this aggregation.
-
getAggregatorFactory
public AggregatorFactory getAggregatorFactory()
Returns the aggregator factory for this aggregation.- Returns:
- the aggregator factory for this aggregation.
-
getOutputName
public String getOutputName()
Returns the output name for this aggregation.- Returns:
- the output name for this aggregation.
-
validateInputType
public void validateInputType(RecordTokenType inputType)
Validate the input types to this aggregation.- Parameters:
inputType- the type of the record used as input to the aggregation- Throws:
DRException- if a subexpression evaluates to a type incompatible with the aggregation or parent function, or if a referenced field is not present in the input type
-
avg
public static Aggregation avg(String input)
Create an average value aggregation for the given input.- Parameters:
input- input field name- Returns:
- average value aggregation
-
avg
public static Aggregation avg(ScalarValuedFunction input)
Create an average value aggregation for the given input.- Parameters:
input- input function- Returns:
- average value aggregation
-
count
public static Aggregation count()
Create a count aggregation for all rows within a group. Equivalent to the SQL count(*).- Returns:
- a count aggregation for all rows within a group.
-
count
public static Aggregation count(String input)
Create a value count aggregation for the given input. This aggregation only counts non-null values.- Parameters:
input- input field name- Returns:
- non-null value count aggregation
-
count
public static Aggregation count(ScalarValuedFunction input)
Create a value count aggregation for the given input. This aggregation only counts non-null values.- Parameters:
input- input function- Returns:
- non-null value count aggregation
-
corr
public static Aggregation corr(String input1, String input2)
Create a correlation aggregation for the given inputs.- Parameters:
input1- input field nameinput2- input field name- Returns:
- correlation aggregation
-
corr
public static Aggregation corr(ScalarValuedFunction input1, ScalarValuedFunction input2)
Create a correlation aggregation for the given inputs.- Parameters:
input1- input functioninput2- input function- Returns:
- correlation aggregation
-
covar
public static Aggregation covar(String input1, String input2)
Create a covariance aggregation for the given inputs.- Parameters:
input1- input field nameinput2- input field name- Returns:
- covariance (population) aggregation
-
covar
public static Aggregation covar(String input1, String input2, boolean sample)
Create a covariance aggregation for the given inputs.- Parameters:
input1- input field nameinput2- input field namesample- whether to adjust for sampling- Returns:
- covariance aggregation
-
covar
public static Aggregation covar(ScalarValuedFunction input1, ScalarValuedFunction input2)
Create a covariance aggregation for the given inputs.- Parameters:
input1- input functioninput2- input function- Returns:
- covariance (population) aggregation
-
covar
public static Aggregation covar(ScalarValuedFunction input1, ScalarValuedFunction input2, boolean sample)
Create a covariance aggregation for the given inputs.- Parameters:
input1- input functioninput2- input functionsample- whether to adjust for sampling- Returns:
- covariance aggregation
-
geoAvg
public static Aggregation geoAvg(String input)
Create a geometric average value aggregation for the given input.- Parameters:
input- input field name- Returns:
- geometric average value aggregation
-
geoAvg
public static Aggregation geoAvg(ScalarValuedFunction input)
Create a geometric average value aggregation for the given input.- Parameters:
input- input function- Returns:
- geometric average value aggregation
-
harmAvg
public static Aggregation harmAvg(String input)
Create an harmonic average value aggregation for the given input.- Parameters:
input- input field name- Returns:
- harmonic average value aggregation
-
harmAvg
public static Aggregation harmAvg(ScalarValuedFunction input)
Create an harmonic average value aggregation for the given input.- Parameters:
input- input function- Returns:
- harmonic average value aggregation
-
kurtosis
public static Aggregation kurtosis(String input)
Create a kurtosis aggregation for the given input.- Parameters:
input- input field name- Returns:
- kurtosis (population) aggregation
-
kurtosis
public static Aggregation kurtosis(String input, boolean sample)
Create a kurtosis aggregation for the given input.- Parameters:
input- input field namesample- whether to adjust for sampling- Returns:
- kurtosis aggregation
-
kurtosis
public static Aggregation kurtosis(ScalarValuedFunction input)
Create a kurtosis aggregation for the given input.- Parameters:
input- input function- Returns:
- kurtosis (population) aggregation
-
kurtosis
public static Aggregation kurtosis(ScalarValuedFunction input, boolean sample)
Create a kurtosis aggregation for the given input.- Parameters:
input- input functionsample- whether to adjust for sampling- Returns:
- kurtosis aggregation
-
max
public static Aggregation max(String input)
Create a maximum value aggregation for the given input.- Parameters:
input- input field name- Returns:
- maximum value aggregation
-
max
public static Aggregation max(ScalarValuedFunction input)
Create a maximum value aggregation for the given input.- Parameters:
input- input field name- Returns:
- maximum value aggregation
-
min
public static Aggregation min(String input)
Create a minimum value aggregation for the given input.- Parameters:
input- input field name- Returns:
- minimum value aggregation
-
min
public static Aggregation min(ScalarValuedFunction input)
Create a minimum value aggregation for the given input.- Parameters:
input- input function- Returns:
- minimum value aggregation
-
moment
public static Aggregation moment(String input, int k)
Create a central moment aggregation for the given input.- Parameters:
input- input field namek- the moment to calculate.- Returns:
- central moment aggregation
-
moment
public static Aggregation moment(ScalarValuedFunction input, int k)
Create a central moment aggregation for the given input.- Parameters:
input- input field namek- the moment to calculate.- Returns:
- central moment aggregation
-
skewness
public static Aggregation skewness(String input)
Create a skewness aggregation for the given input.- Parameters:
input- input field name- Returns:
- skewness (population) aggregation
-
skewness
public static Aggregation skewness(String input, boolean sample)
Create a skewness aggregation for the given input.- Parameters:
input- input field namesample- whether to adjust for sampling- Returns:
- skewness aggregation
-
skewness
public static Aggregation skewness(ScalarValuedFunction input)
Create a skewness aggregation for the given input.- Parameters:
input- input function- Returns:
- skewness (population) aggregation
-
skewness
public static Aggregation skewness(ScalarValuedFunction input, boolean sample)
Create a skewness aggregation for the given input.- Parameters:
input- input functionsample- whether to adjust for sampling- Returns:
- skewness aggregation
-
stddev
public static Aggregation stddev(String input)
Create a standard deviation aggregation for the given input.- Parameters:
input- input field name- Returns:
- standard deviation (population) aggregation
-
stddev
public static Aggregation stddev(String input, boolean sample)
Create a standard deviation aggregation for the given input.- Parameters:
input- input field namesample- whether to adjust for sampling- Returns:
- standard deviation aggregation
-
stddev
public static Aggregation stddev(ScalarValuedFunction input)
Create a standard deviation aggregation for the given input.- Parameters:
input- input function- Returns:
- standard deviation (population) aggregation
-
stddev
public static Aggregation stddev(ScalarValuedFunction input, boolean sample)
Create a standard deviation aggregation for the given input.- Parameters:
input- input functionsample- whether to adjust for sampling- Returns:
- standard deviation aggregation
-
sum
public static Aggregation sum(String input)
Create a value summation aggregation for the given input.- Parameters:
input- input field name- Returns:
- summation aggregation type
-
sum
public static Aggregation sum(ScalarValuedFunction input)
Create a value summation aggregation for the given input.- Parameters:
input- input field name- Returns:
- summation aggregation type
-
sumSquares
public static Aggregation sumSquares(String input)
Create a sum-squares aggregation for the given input.- Parameters:
input- input field name- Returns:
- summation aggregation type
-
sumSquares
public static Aggregation sumSquares(ScalarValuedFunction input)
Create a sum-squares aggregation for the given input.- Parameters:
input- input function- Returns:
- summation aggregation type
-
var
public static Aggregation var(String input)
Create a variance aggregation for the given input.- Parameters:
input- input field name- Returns:
- variance (population) aggregation
-
var
public static Aggregation var(String input, boolean sample)
Create a variance aggregation for the given input.- Parameters:
input- input field namesample- whether to adjust for sampling- Returns:
- variance (sample) aggregation
-
var
public static Aggregation var(ScalarValuedFunction input)
Create a variance aggregation for the given input.- Parameters:
input- input function- Returns:
- variance (population) aggregation
-
var
public static Aggregation var(ScalarValuedFunction input, boolean sample)
Create a variance aggregation for the given input.- Parameters:
input- input functionsample- whether to adjust for sampling- Returns:
- variance (sample) aggregation
-
-