Class ComboAggregateFactory
- All Implemented Interfaces:
AggregationStateFactory
,Serializable
public class ComboAggregateFactory extends Object implements Serializable, AggregationStateFactory
Table.by(AggregationStateFactory)
.
The intended use of this class is to call the AggCombo(ComboBy...)
method with a set of aggregations
defined by:
AggMin(java.lang.String...)
AggMax(java.lang.String...)
AggSum(java.lang.String...)
AggAbsSum(java.lang.String...)
AggVar(java.lang.String...)
AggAvg(java.lang.String...)
AggWAvg(java.lang.String, java.lang.String...)
AggWSum(java.lang.String, java.lang.String...)
AggMed(java.lang.String...)
AggPct(double, java.lang.String...)
AggStd(java.lang.String...)
AggFirst(java.lang.String...)
AggLast(java.lang.String...)
AggCount(java.lang.String)
AggCountDistinct(java.lang.String...)
AggDistinct(java.lang.String...)
AggArray(java.lang.String...)
AggSortedFirst(java.lang.String, java.lang.String...)
AggSortedLast(java.lang.String, java.lang.String...)
For example, to produce a table with several aggregations on the LastPrice of a Trades table:
ohlc=trades.by(AggCombo(AggFirst("Open=LastPrice"), AggLast("Close=LastPrice"), AggMax("High=LastPrice"), AggMin("Low=LastPrice"), AggSum("Volume=Size"), AggWAvg("Size", "VWAP=LastPrice"), "Symbol")
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ComboAggregateFactory.ComboBy
static class
ComboAggregateFactory.ComboByImpl
static class
ComboAggregateFactory.CountComboBy
static class
ComboAggregateFactory.NullComboBy
-
Field Summary
Fields Modifier and Type Field Description static String
ROLLUP_COLUMN_SUFFIX
static String
ROLLUP_DISTINCT_SSM_COLUMN_ID
-
Constructor Summary
Constructors Constructor Description ComboAggregateFactory(ComboAggregateFactory.ComboBy... aggregations)
ComboAggregateFactory(Collection<ComboAggregateFactory.ComboBy> aggregations)
ComboAggregateFactory(Collection<ComboAggregateFactory.ComboBy> aggregations, boolean isRollup, boolean secondLevelRollup)
-
Method Summary
Modifier and Type Method Description static ComboAggregateFactory.ComboBy
Agg(AggregationStateFactory factory, String... matchPairs)
Create an aggregation.static ComboAggregateFactory.ComboBy
Agg(AggType factoryType, String... matchPairs)
Create an aggregation.static ComboAggregateFactory.ComboBy
AggAbsSum(String... matchPairs)
Create an absolute sum aggregation, equivalent toTable.absSumBy(String...)
.static ComboAggregateFactory.ComboBy
AggArray(String... matchPairs)
Create an array aggregation, equivalent toTable.by(String...)
.static ComboAggregateFactory.ComboBy
AggAvg(String... matchPairs)
Create an average aggregation, equivalent toTable.avgBy(String...)
.static ComboAggregateFactory
AggCombo(ComboAggregateFactory.ComboBy... aggregations)
Create a new ComboAggregateFactory suitable for passing toTable.by(AggregationStateFactory, String...)
.static ComboAggregateFactory.ComboBy
AggCount(String resultColumn)
Create an count aggregation, equivalent toTable.countBy(String)
.static ComboAggregateFactory.ComboBy
AggCountDistinct(boolean countNulls, String... matchPairs)
Create a distinct count aggregation.static ComboAggregateFactory.ComboBy
AggCountDistinct(String... matchPairs)
Create a distinct count aggregation.static ComboAggregateFactory.ComboBy
AggDistinct(boolean countNulls, String... matchPairs)
Create a distinct aggregation.static ComboAggregateFactory.ComboBy
AggDistinct(String... matchPairs)
Create a distinct aggregation.static ComboAggregateFactory.ComboBy
AggFirst(String... matchPairs)
Create a first aggregation, equivalent toTable.firstBy(String...)
.static ComboAggregateFactory.ComboBy
AggFormula(String formula, String formulaParam, String... matchPairs)
Create a formula aggregation.static ComboAggregateFactory.ComboBy
AggLast(String... matchPairs)
Create a last aggregation, equivalent toTable.lastBy(String...)
.static ComboAggregateFactory.ComboBy
AggMax(String... matchPairs)
Create a maximum aggregation, equivalent toTable.maxBy(String...)
.static ComboAggregateFactory.ComboBy
AggMed(String... matchPairs)
Create a median aggregation, equivalent toTable.medianBy(String...)
.static ComboAggregateFactory.ComboBy
AggMin(String... matchPairs)
Create a minimum aggregation, equivalent toTable.minBy(String...)
.static ComboAggregateFactory.ComboBy
AggPct(double percentile, boolean averageMedian, String... matchPairs)
Create a percentile aggregation.static ComboAggregateFactory.ComboBy
AggPct(double percentile, String... matchPairs)
Create a percentile aggregation.static ComboAggregateFactory.ComboBy
AggSortedFirst(String[] sortColumns, String... matchPairs)
Create a sorted first aggregation, equivalent toSortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String)
.static ComboAggregateFactory.ComboBy
AggSortedFirst(String sortColumn, String... matchPairs)
Create a sorted first aggregation, equivalent toSortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String)
.static ComboAggregateFactory.ComboBy
AggSortedLast(String[] sortColumns, String... matchPairs)
Create a sorted last aggregation, equivalent toSortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String)
.static ComboAggregateFactory.ComboBy
AggSortedLast(String sortColumn, String... matchPairs)
Create a sorted last aggregation, equivalent toSortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String)
.static ComboAggregateFactory.ComboBy
AggStd(String... matchPairs)
Create a standard deviation aggregation, equivalent toTable.stdBy(String...)
.static ComboAggregateFactory.ComboBy
AggSum(String... matchPairs)
Create a summation aggregation, equivalent toTable.sumBy(String...)
.static ComboAggregateFactory.ComboBy
AggUnique(boolean countNulls, Object noKeyValue, Object nonUniqueValue, String... matchPairs)
Create a Unique aggregation.static ComboAggregateFactory.ComboBy
AggUnique(boolean countNulls, String... matchPairs)
Create a Unique aggregation.static ComboAggregateFactory.ComboBy
AggUnique(String... matchPairs)
Create a Unique aggregation.static ComboAggregateFactory.ComboBy
AggVar(String... matchPairs)
Create a variance aggregation, equivalent toTable.varBy(String...)
.static ComboAggregateFactory.ComboBy
AggWAvg(String weight, String... matchPairs)
Create a weighted average aggregation, equivalent toTable.wavgBy(String, String...)
.static ComboAggregateFactory.ComboBy
AggWSum(String weight, String... matchPairs)
Create a weighted sum aggregation, equivalent toTable.wsumBy(String, String...)
.ComboAggregateFactory
forRollup(boolean includeConstituents)
List<MatchPair>
getMatchPairs()
AggregationMemoKey
getMemoKey()
Produces a MemoKey for this aggregation state factory.AggregationContextFactory
makeAggregationContextFactory()
ComboAggregateFactory
rollupFactory()
Create a factory for performing rollups.String
toString()
ComboAggregateFactory
withNulls(Map<String,Class> nullColumns)
Create a new factory that will have columns with all null values.
-
Field Details
-
ROLLUP_DISTINCT_SSM_COLUMN_ID
- See Also:
- Constant Field Values
-
ROLLUP_COLUMN_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ComboAggregateFactory
-
ComboAggregateFactory
public ComboAggregateFactory(Collection<ComboAggregateFactory.ComboBy> aggregations, boolean isRollup, boolean secondLevelRollup) -
ComboAggregateFactory
-
-
Method Details
-
AggCombo
Create a new ComboAggregateFactory suitable for passing toTable.by(AggregationStateFactory, String...)
.- Parameters:
aggregations
- the aggregations to compute- Returns:
- a new table with the specified aggregations.
-
AggFormula
public static ComboAggregateFactory.ComboBy AggFormula(String formula, String formulaParam, String... matchPairs)Create a formula aggregation.- Parameters:
formula
- the formula to apply to each groupformulaParam
- the parameter name within the formulamatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggMin
Create a minimum aggregation, equivalent toTable.minBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggMax
Create a maximum aggregation, equivalent toTable.maxBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggSum
Create a summation aggregation, equivalent toTable.sumBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggAbsSum
Create an absolute sum aggregation, equivalent toTable.absSumBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggVar
Create a variance aggregation, equivalent toTable.varBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggAvg
Create an average aggregation, equivalent toTable.avgBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggWAvg
Create a weighted average aggregation, equivalent toTable.wavgBy(String, String...)
.- Parameters:
weight
- the name of the column to use as the weight for the averagematchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggWSum
Create a weighted sum aggregation, equivalent toTable.wsumBy(String, String...)
.- Parameters:
weight
- the name of the column to use as the weight for the summatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggMed
Create a median aggregation, equivalent toTable.medianBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggStd
Create a standard deviation aggregation, equivalent toTable.stdBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggFirst
Create a first aggregation, equivalent toTable.firstBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggLast
Create a last aggregation, equivalent toTable.lastBy(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggSortedFirst
public static ComboAggregateFactory.ComboBy AggSortedFirst(String sortColumn, String... matchPairs)Create a sorted first aggregation, equivalent toSortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String)
.- Parameters:
sortColumn
- the column to sort bymatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggSortedLast
Create a sorted last aggregation, equivalent toSortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String)
.- Parameters:
sortColumn
- the column to sort bymatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggSortedFirst
public static ComboAggregateFactory.ComboBy AggSortedFirst(String[] sortColumns, String... matchPairs)Create a sorted first aggregation, equivalent toSortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String)
.- Parameters:
sortColumns
- the column to sort bymatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggSortedLast
public static ComboAggregateFactory.ComboBy AggSortedLast(String[] sortColumns, String... matchPairs)Create a sorted last aggregation, equivalent toSortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String)
.- Parameters:
sortColumns
- the columns to sort bymatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggArray
Create an array aggregation, equivalent toTable.by(String...)
.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggCount
Create an count aggregation, equivalent toTable.countBy(String)
.- Parameters:
resultColumn
- the name of the result column containing the count of each group- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggCountDistinct
Create a distinct count aggregation. The output column contains the number of distinct values for the input column in that group.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
. Null values are not counted.
-
AggCountDistinct
public static ComboAggregateFactory.ComboBy AggCountDistinct(boolean countNulls, String... matchPairs)Create a distinct count aggregation. The output column contains the number of distinct values for the input column in that group.- Parameters:
countNulls
- if true null values are counted as a distinct value, otherwise null values are ignoredmatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggDistinct
Create a distinct aggregation. The output column contains aDbArrayBase
with the distinct values for the input column within the group.- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
. Null values are ignored.
-
AggDistinct
Create a distinct aggregation. The output column contains aDbArrayBase
with the distinct values for the input column within the group.- Parameters:
countNulls
- if true, then null values are included in the result, otherwise null values are ignoredmatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggUnique
Create a Unique aggregation. The output column contains a value of the same type as the input column which contains
- The "no key value" - if there are no values present
- The single unique value - if there is only a single value present
- The "non unique value" - if there are more than 1 distinct values present
- Parameters:
matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggUnique
Create a Unique aggregation. The output column contains a value of the same type as the input column which contains
- The "no key value" - if there are no values present
- The single unique value - if there is only a single value present
- The "non unique value" - if there are more than 1 distinct values present
- Parameters:
countNulls
- if true, then null values are included in the result, otherwise null values are ignoredmatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
. Output columns contain null if there are no values present or there are more than 1 distinct values present.
-
AggUnique
public static ComboAggregateFactory.ComboBy AggUnique(boolean countNulls, Object noKeyValue, Object nonUniqueValue, String... matchPairs)Create a Unique aggregation. The output column contains a value of the same type as the input column which contains
- The "no key value" - if there are no values present
- The single unique value - if there is only a single value present
- The "non unique value" - if there are more than 1 distinct values present
- Parameters:
countNulls
- if true, then null values are included in the result, otherwise null values are ignorednoKeyValue
- the value to use if there are no values presentnonUniqueValue
- the value to use if there are more than 1 values presentmatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggPct
Create a percentile aggregation.- Parameters:
percentile
- the percentile to calculatematchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
AggPct
public static ComboAggregateFactory.ComboBy AggPct(double percentile, boolean averageMedian, String... matchPairs)Create a percentile aggregation.- Parameters:
percentile
- the percentile to calculateaverageMedian
- if true, then when the upper values and lower values have an equal size; average the highest lower value and lowest upper value to produce the median value for integers, longs, doubles, and floatsmatchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
Agg
public static ComboAggregateFactory.ComboBy Agg(AggregationStateFactory factory, String... matchPairs)Create an aggregation.- Parameters:
factory
- aggregation factory.matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
Agg
Create an aggregation.- Parameters:
factoryType
- aggregation factory type.matchPairs
- the columns to apply the aggregation to in the form Output=Input, if the Output and Input have the same name, then the column name can be specified.- Returns:
- a ComboBy object suitable for passing to
AggCombo(ComboBy...)
-
rollupFactory
Create a factory for performing rollups. -
forRollup
-
withNulls
Create a new factory that will have columns with all null values. Used by rollup to empty out unused grouping columns.- Parameters:
nullColumns
- a map of column names to types.- Returns:
- a new ComboAggregateFactory that will produce null values for the given columns.
-
getMemoKey
Description copied from interface:AggregationStateFactory
Produces a MemoKey for this aggregation state factory.If two AggregationStateFactories have equal memoKeys, then
Table.by(com.illumon.iris.db.v2.by.AggregationStateFactory, com.illumon.iris.db.v2.select.SelectColumn...)
operations that have the same group by columns may be memoized. In that case instead of recomputing the result; the original result will be used.If null is returned, the operation will not be memoized.
- Specified by:
getMemoKey
in interfaceAggregationStateFactory
- Returns:
- an AggregationMemoKey, null if this operation can not be memoized.
-
toString
-
getMatchPairs
-
makeAggregationContextFactory
-