Interface Aggregation

All Known Subinterfaces:
RollupAggregation
All Known Implementing Classes:
Aggregations, ColumnAggregation, ColumnAggregations, Count, FirstRowKey, LastRowKey, NullColumns, Partition, RollupAggregationBase

public interface Aggregation
Represents an aggregation that can be applied to a table.
See Also:
  • Method Details

    • of

      static ColumnAggregation of(AggSpec spec, String pair)
      Combine an AggSpec and an input/output column name pair into a ColumnAggregation.
      Parameters:
      spec - The aggregation specifier to apply to the column name pair
      pair - The input/output column name pair
      Returns:
      The aggregation
    • of

      static Aggregation of(AggSpec spec, String... pairs)
      Combine an AggSpec and one or more input/output column name pairs into a ColumnAggregation or ColumnAggregations.
      Parameters:
      spec - The aggregation specifier to apply to the column name pair(s)
      pairs - The input/output column name pair or pairs
      Returns:
      The aggregation
    • of

      static Aggregation of(AggSpec spec, List<String> pairs)
      Combine an AggSpec and one or more input/output column name pairs into a ColumnAggregation or ColumnAggregations.
      Parameters:
      spec - The aggregation specifier to apply to the column name pair(s)
      pairs - The input/output column name pair or pairs
      Returns:
      The aggregation
    • of

      static Aggregation of(Aggregation... aggregations)
      Pass through a single Aggregation, or combine many into an Aggregations.
      Parameters:
      aggregations - The aggregations to combine
      Returns:
      The combined aggregation
    • of

      @SafeVarargs static <INPUT_TYPE> Aggregation of(BiFunction<ColumnName,INPUT_TYPE,ColumnAggregation> columnAggFactory, String inputColumn, INPUT_TYPE... inputs)
      Create a single or compound Aggregation from a single input column and one or more per-aggregation input values.
      Parameters:
      columnAggFactory - A factory for combining an input column and input value into a aggregation
      inputColumn - The input column for each component of the resulting aggregation
      inputs - The input values to combine with the input column via the factory
      Returns:
      The combined aggregation
    • AggAbsSum

      static Aggregation AggAbsSum(String... pairs)
      Create an absolute sum aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggApproxPct

      static Aggregation AggApproxPct(double percentile, String... pairs)
      Create an approximate percentile aggregation for the supplied percentile and column name pairs with the default T-Digest compression factor.
      Parameters:
      percentile - The percentile to use for all component aggregations
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggApproxPct

      static Aggregation AggApproxPct(double percentile, double compression, String... pairs)
      Create an approximate percentile aggregation for the supplied percentile, T-Digest compression factor, and column name pairs.
      Parameters:
      percentile - The percentile to use for all component aggregations
      compression - T-Digest compression factor; must be > 1, should probably be < 1000
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggApproxPct

      static Aggregation AggApproxPct(String inputColumn, PercentileOutput... percentileOutputs)
      Create an approximate percentile aggregation for the supplied input column name and percentile/output column name pairs with the default T-Digest compression factor.
      Parameters:
      inputColumn - The input column name
      percentileOutputs - The percentile/output column name pairs for the component aggregations; see PctOut(double, String).
      Returns:
      The aggregation
    • AggApproxPct

      static Aggregation AggApproxPct(String inputColumn, double compression, PercentileOutput... percentileOutputs)
      Create an approximate percentile aggregation for the supplied input column name, T-Digest compression factor, and percentile/output column name pairs.
      Parameters:
      inputColumn - The input column name
      compression - T-Digest compression factor; must be > 1, should probably be < 1000
      percentileOutputs - The percentile/output column name pairs for the component aggregations; see PctOut(double, String).
      Returns:
      The aggregation
    • AggAvg

      static Aggregation AggAvg(String... pairs)
      Create an average (arithmetic mean) aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggCount

      static Count AggCount(String resultColumn)
      Create a count aggregation with the supplied output column name.
      Parameters:
      resultColumn - The output column name
      Returns:
      The aggregation
    • AggCountDistinct

      static Aggregation AggCountDistinct(String... pairs)
      Create a count distinct aggregation for the supplied column name pairs. This will not count null values from the input column(s).
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggCountDistinct

      static Aggregation AggCountDistinct(boolean countNulls, String... pairs)
      Create a count distinct aggregation for the supplied column name pairs. This will count null values from the input column(s) if countNulls is true.
      Parameters:
      countNulls - Whether null values should be counted; see AggSpecCountDistinct.countNulls()}
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggDistinct

      static Aggregation AggDistinct(String... pairs)
      Create a distinct aggregation for the supplied column name pairs. This will not include null values in the output column(s).
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggDistinct

      static Aggregation AggDistinct(boolean includeNulls, String... pairs)
      Create a distinct aggregation for the supplied column name pairs. This will include null values in the output column(s) if includeNulls is true.
      Parameters:
      includeNulls - Whether null values should be included; see AggSpecDistinct.includeNulls()
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggFirst

      static Aggregation AggFirst(String... pairs)
      Create a first aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggFirstRowKey

      static FirstRowKey AggFirstRowKey(String resultColumn)
      Create a first row key aggregation with the supplied result column.
      Parameters:
      resultColumn - The output column name
      Returns:
      The aggregation
    • AggFormula

      static Aggregation AggFormula(String formula, String paramToken, String... pairs)
      Create a formula aggregation with the supplied formula, paramToken, and column name pairs.
      Parameters:
      formula - The formula to use for all input columns to produce all output columns
      paramToken - The parameter token to replace with the input column name in formula
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggFreeze

      static Aggregation AggFreeze(String... pairs)
      Create a freeze aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggGroup

      static Aggregation AggGroup(String... pairs)
      Create a group aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggLast

      static Aggregation AggLast(String... pairs)
      Create a last aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggLastRowKey

      static LastRowKey AggLastRowKey(String resultColumn)
      Create a last row key aggregation with the supplied result column.
      Parameters:
      resultColumn - The output column name
      Returns:
      The aggregation
    • AggMax

      static Aggregation AggMax(String... pairs)
      Create a max aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggMed

      static Aggregation AggMed(String... pairs)
      Create a median aggregation for the supplied column name pairs. For numeric types, if there are an even number of values the result will be an average of the two middle values.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggMed

      static Aggregation AggMed(boolean average, String... pairs)
      Create a median aggregation for the supplied column name pairs. For numeric types, if there are an even number of values the result will be an average of the two middle values if average is true, else the result will be the lower of the two middle values.
      Parameters:
      average - Whether to average the middle two values for even-sized result sets of numeric types; see AggSpecMedian.averageEvenlyDivided()
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggMin

      static Aggregation AggMin(String... pairs)
      Create a min aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggPartition

      static Partition AggPartition(String resultColumn)
      Create a partition aggregation with the supplied output column name and group-by columns included in the output sub-tables.
      Parameters:
      resultColumn - The output column name
      Returns:
      The aggregation
    • AggPartition

      static Partition AggPartition(String resultColumn, boolean includeGroupByColumns)
      Create a partition aggregation with the supplied output column name.
      Parameters:
      resultColumn - The output column name
      includeGroupByColumns - Whether to include group-by columns in the result
      Returns:
      The aggregation
    • AggPct

      static Aggregation AggPct(double percentile, String... pairs)
      Create a percentile aggregation for the supplied percentile and column name pairs.
      Parameters:
      percentile - The percentile to use for all component aggregations
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggPct

      static Aggregation AggPct(double percentile, boolean average, String... pairs)
      Create a percentile aggregation for the supplied percentile and column name pairs. If the percentile equally divides the value space, the result will be the average of the values immediately below and above if average is true.
      Parameters:
      percentile - The percentile to use for all component aggregations
      average - Whether to average the lower and higher values for evenly divided result sets of numeric types; see AggSpecPercentile.averageEvenlyDivided()
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggPct

      static Aggregation AggPct(String inputColumn, PercentileOutput... percentileOutputs)
      Create a percentile aggregation for the supplied input column name and percentile/output column name pairs.
      Parameters:
      inputColumn - The input column name
      percentileOutputs - The percentile/output column name pairs for the component aggregations; see PctOut(double, String).
      Returns:
      The aggregation
    • AggPct

      static Aggregation AggPct(String inputColumn, boolean average, PercentileOutput... percentileOutputs)
      Create a percentile aggregation for the supplied input column name and percentile/output column name pairs. If the percentile equally divides the value space, the result will be the average of the values immediately below and above if average is true.
      Parameters:
      inputColumn - The input column name
      average - Whether to average the lower and higher values for evenly divided result sets of numeric types; see AggSpecPercentile.averageEvenlyDivided()
      percentileOutputs - The percentile/output column name pairs for the component aggregations; see PctOut(double, String).
      Returns:
      The aggregation
    • AggSortedFirst

      static Aggregation AggSortedFirst(String sortColumn, String... pairs)
      Create a sorted first aggregation for the supplied sort column name and input/output column name pairs.
      Parameters:
      sortColumn - The sort column name
      pairs - The input/output column name pairs for the component aggregations
      Returns:
      The aggregation
    • AggSortedFirst

      static Aggregation AggSortedFirst(Collection<? extends String> sortColumns, String... pairs)
      Create a sorted first aggregation for the supplied sort column names and input/output column name pairs.
      Parameters:
      sortColumns - The sort column names
      pairs - The input/output column name pairs for the component aggregations
      Returns:
      The aggregation
    • AggSortedLast

      static Aggregation AggSortedLast(String sortColumn, String... pairs)
      Create a sorted last aggregation for the supplied sort column name and input/output column name pairs.
      Parameters:
      sortColumn - The sort column name
      pairs - The input/output column name pairs for the component aggregations
      Returns:
      The aggregation
    • AggSortedLast

      static Aggregation AggSortedLast(Collection<? extends String> sortColumns, String... pairs)
      Create a sorted last aggregation for the supplied sort column names and input/output column name pairs.
      Parameters:
      sortColumns - The sort column names
      pairs - The input/output column name pairs for the component aggregations
      Returns:
      The aggregation
    • AggStd

      static Aggregation AggStd(String... pairs)
      Create a sample standard deviation aggregation for the supplied column name pairs. Sample standard deviation is computed using Bessel's correction (https://en.wikipedia.org/wiki/Bessel%27s_correction), which ensures that the sample variance will be an unbiased estimator of population variance.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggSum

      static Aggregation AggSum(String... pairs)
      Create a sum aggregation for the supplied column name pairs.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggTDigest

      static Aggregation AggTDigest(String... pairs)
      Create a T-Digest aggregation for the supplied column name pairs with the default T-Digest compression factor.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggTDigest

      static Aggregation AggTDigest(double compression, String... pairs)
      Create a T-Digest aggregation for the supplied column name pairs with the supplied compression factor.
      Parameters:
      compression - T-Digest compression factor; must be > 1, should probably be < 1000
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggUnique

      static Aggregation AggUnique(String... pairs)
      Create a unique aggregation for the supplied column name pairs. This will not consider null values when determining if a group has a single unique value. Non-unique groups will have null values in the output column.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggUnique

      static Aggregation AggUnique(boolean includeNulls, String... pairs)
      Create a unique aggregation for the supplied column name pairs. This will consider null values when determining if a group has a single unique value if includeNulls is true. Non-unique groups will have null values in the output column.
      Parameters:
      includeNulls - Whether to consider null values towards uniqueness; see AggSpecUnique.includeNulls()
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggUnique

      static Aggregation AggUnique(boolean includeNulls, UnionObject nonUniqueSentinel, String... pairs)
      Create a unique aggregation for the supplied column name pairs. This will consider null values when determining if a group has a single unique value if includeNulls is true. Non-unique groups will have the value wrapped by nonUniqueSentinel in the output column.
      Parameters:
      includeNulls - Whether to consider null values towards uniqueness
      nonUniqueSentinel - The value to output for non-unique groups
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggVar

      static Aggregation AggVar(String... pairs)
      Create a sample variance aggregation for the supplied column name pairs. Sample variance is computed using Bessel's correction (https://en.wikipedia.org/wiki/Bessel%27s_correction), which ensures that the sample variance will be an unbiased estimator of population variance.
      Parameters:
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggWAvg

      static Aggregation AggWAvg(String weightColumn, String... pairs)
      Create a weighted average aggregation for the supplied weight column name and column name pairs.
      Parameters:
      weightColumn - The weight column name
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • AggWSum

      static Aggregation AggWSum(String weightColumn, String... pairs)
      Create a weighted sum aggregation for the supplied weight column name and column name pairs.
      Parameters:
      weightColumn - The weight column name
      pairs - The input/output column name pairs
      Returns:
      The aggregation
    • PctOut

      static PercentileOutput PctOut(double percentile, String outputColumn)
      Make a percentile/output column name pair. This allows for strongly-typed input to various approximate percentile and percentile aggregation factory methods.
      Parameters:
      percentile - The percentile for the aggregation
      outputColumn - The output column name to associate with the percentile
      Returns:
      The percentile/output column name pair
      See Also:
    • visitAll

      static void visitAll(Aggregation.Visitor visitor)
      Calls every single visit method of visitor with a null object.
      Parameters:
      visitor - the visitor
    • walk

      <V extends Aggregation.Visitor> V walk(V visitor)
      Glue method to deliver this Aggregation to a AggSpec.Visitor.
      Parameters:
      visitor - The visitor
      Returns:
      The visitor