Class ComboAggregateFactory

java.lang.Object
com.illumon.iris.db.v2.by.ComboAggregateFactory
All Implemented Interfaces:
AggregationStateFactory, Serializable

public class ComboAggregateFactory
extends Object
implements Serializable, AggregationStateFactory
The ComboAggregateFactory combines one or more aggregations into an operator for use with Table.by(AggregationStateFactory).

The intended use of this class is to call the AggCombo(ComboBy...) method with a set of aggregations defined by:

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
  • Field Details

  • Constructor Details

  • Method Details

    • AggCombo

      public static ComboAggregateFactory AggCombo​(ComboAggregateFactory.ComboBy... aggregations)
      Create a new ComboAggregateFactory suitable for passing to Table.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 group
      formulaParam - the parameter name within the formula
      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...)
    • AggMin

      public static ComboAggregateFactory.ComboBy AggMin​(String... matchPairs)
      Create a minimum aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggMax​(String... matchPairs)
      Create a maximum aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggSum​(String... matchPairs)
      Create a summation aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggAbsSum​(String... matchPairs)
      Create an absolute sum aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggVar​(String... matchPairs)
      Create a variance aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggAvg​(String... matchPairs)
      Create an average aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggWAvg​(String weight, String... matchPairs)
      Create a weighted average aggregation, equivalent to Table.wavgBy(String, String...).
      Parameters:
      weight - the name of the column to use as the weight for the average
      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...)
    • AggWSum

      public static ComboAggregateFactory.ComboBy AggWSum​(String weight, String... matchPairs)
      Create a weighted sum aggregation, equivalent to Table.wsumBy(String, String...).
      Parameters:
      weight - the name of the column to use as the weight for the sum
      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...)
    • AggMed

      public static ComboAggregateFactory.ComboBy AggMed​(String... matchPairs)
      Create a median aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggStd​(String... matchPairs)
      Create a standard deviation aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggFirst​(String... matchPairs)
      Create a first aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggLast​(String... matchPairs)
      Create a last aggregation, equivalent to Table.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 to SortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String).
      Parameters:
      sortColumn - the column to sort by
      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...)
    • AggSortedLast

      public static ComboAggregateFactory.ComboBy AggSortedLast​(String sortColumn, String... matchPairs)
      Create a sorted last aggregation, equivalent to SortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String).
      Parameters:
      sortColumn - the column to sort by
      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[] sortColumns, String... matchPairs)
      Create a sorted first aggregation, equivalent to SortedBy.sortedFirstBy(com.illumon.iris.db.tables.Table, java.lang.String).
      Parameters:
      sortColumns - the column to sort by
      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...)
    • AggSortedLast

      public static ComboAggregateFactory.ComboBy AggSortedLast​(String[] sortColumns, String... matchPairs)
      Create a sorted last aggregation, equivalent to SortedBy.sortedLastBy(com.illumon.iris.db.tables.Table, java.lang.String).
      Parameters:
      sortColumns - the columns to sort by
      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...)
    • AggArray

      public static ComboAggregateFactory.ComboBy AggArray​(String... matchPairs)
      Create an array aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggCount​(String resultColumn)
      Create an count aggregation, equivalent to Table.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

      public static ComboAggregateFactory.ComboBy AggCountDistinct​(String... matchPairs)
      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 ignored
      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...)
    • AggDistinct

      public static ComboAggregateFactory.ComboBy AggDistinct​(String... matchPairs)
      Create a distinct aggregation. The output column contains a DbArrayBase 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

      public static ComboAggregateFactory.ComboBy AggDistinct​(boolean countNulls, String... matchPairs)
      Create a distinct aggregation. The output column contains a DbArrayBase 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 ignored
      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

      public static ComboAggregateFactory.ComboBy AggUnique​(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:
      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

      public static ComboAggregateFactory.ComboBy AggUnique​(boolean countNulls, 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 ignored
      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...). 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 ignored
      noKeyValue - the value to use if there are no values present
      nonUniqueValue - the value to use if there are more than 1 values present
      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...)
    • AggPct

      public static ComboAggregateFactory.ComboBy AggPct​(double percentile, String... matchPairs)
      Create a percentile aggregation.
      Parameters:
      percentile - the percentile to calculate
      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...)
    • AggPct

      public static ComboAggregateFactory.ComboBy AggPct​(double percentile, boolean averageMedian, String... matchPairs)
      Create a percentile aggregation.
      Parameters:
      percentile - the percentile to calculate
      averageMedian - 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 floats
      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

      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

      public static ComboAggregateFactory.ComboBy Agg​(AggType factoryType, String... matchPairs)
      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

      public ComboAggregateFactory rollupFactory()
      Create a factory for performing rollups.
    • forRollup

      public ComboAggregateFactory forRollup​(boolean includeConstituents)
    • withNulls

      public ComboAggregateFactory withNulls​(Map<String,​Class> nullColumns)
      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

      public AggregationMemoKey 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 interface AggregationStateFactory
      Returns:
      an AggregationMemoKey, null if this operation can not be memoized.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMatchPairs

      public List<MatchPair> getMatchPairs()
    • makeAggregationContextFactory

      public AggregationContextFactory makeAggregationContextFactory()