Class AggregateWindow

All Implemented Interfaces:
Expression, HasImports

public final class AggregateWindow extends AbstractParametrizedFlux
Applies an aggregate or selector function (any function with a column parameter) to fixed windows of time. See SPEC.

Options

  • every - The duration of windows. [duration]
  • fn - The aggregate function used in the operation. [function]
  • column - The column on which to operate. Defaults to "_value". [string]
  • timeSrc - The time column from which time is copied for the aggregate record. Defaults to "_stop". [string]
  • timeDst - The “time destination” column to which time is copied for the aggregate record. Defaults to "_time". [string]
  • createEmpty - For windows without data, this will create an empty window and fill it with a null aggregate value. Defaults to true. [boolean]

Example

 Flux flux = Flux
     .from("telegraf")
     .aggregateWindow(10L, ChronoUnit.SECONDS, "mean");

 Flux flux = Flux
     .from("telegraf")
     .aggregateWindow()
         .withEvery("10s")
         .withAggregateFunction("sum")
         .withColumn("_value")
         .withTimeSrc("_stop")
         .withTimeDst("_time")
         .withCreateEmpty(true);

 Flux flux = Flux
     .from("telegraf")
     .aggregateWindow()
         .withEvery(5L, ChronoUnit.MINUTES)
         .withFunction("tables |> quantile(q: 0.99, column:column)");
 
Author:
Jakub Bednar (13/05/2020 08:41)
  • Constructor Details

    • AggregateWindow

      public AggregateWindow(@Nonnull Flux source)
  • Method Details

    • operatorName

      @Nonnull protected String operatorName()
      Specified by:
      operatorName in class AbstractParametrizedFlux
      Returns:
      name of function
    • withEvery

      @Nonnull public AggregateWindow withEvery(@Nonnull Long every, @Nonnull ChronoUnit everyUnit)
      Parameters:
      every - The duration of windows.
      everyUnit - a ChronoUnit determining how to interpret the every.
      Returns:
      this
    • withEvery

      @Nonnull public AggregateWindow withEvery(@Nonnull String every)
      Parameters:
      every - The duration of windows.
      Returns:
      this
    • withFunction

      @Nonnull public AggregateWindow withFunction(@Nonnull String function)
      Parameters:
      function - specifies the aggregate operation to perform.
      Returns:
      this
    • withAggregateFunction

      @Nonnull public AggregateWindow withAggregateFunction(@Nonnull String namedFunction)
      Parameters:
      namedFunction - specifies the named aggregate operation to perform.
      Returns:
      this
    • withColumn

      @Nonnull public AggregateWindow withColumn(@Nonnull String column)
      Parameters:
      column - The column on which to operate.
      Returns:
      this
    • withTimeSrc

      @Nonnull public AggregateWindow withTimeSrc(@Nonnull String timeSrc)
      Parameters:
      timeSrc - The time column from which time is copied for the aggregate record.
      Returns:
      this
    • withTimeDst

      @Nonnull public AggregateWindow withTimeDst(@Nonnull String timeDst)
      Parameters:
      timeDst - The “time destination” column to which time is copied for the aggregate record.
      Returns:
      this
    • withCreateEmpty

      @Nonnull public AggregateWindow withCreateEmpty(boolean createEmpty)
      Parameters:
      createEmpty - For windows without data, this will create an empty window and fill it with a null aggregate value.
      Returns:
      this
    • withOffset

      @Nonnull public AggregateWindow withOffset(@Nonnull Long amount, @Nonnull ChronoUnit unit)
      Parameters:
      amount - The offset of windows.
      unit - a ChronoUnit determining how to interpret the amount.
      Returns:
      this
    • withOffset

      @Nonnull public AggregateWindow withOffset(@Nonnull String offset)
      Parameters:
      offset - The offset of windows.
      Returns:
      this
    • collectImports

      public void collectImports(@Nonnull Set<String> collectedImports)
      Description copied from class: Flux
      Collects all imports of the flux.
      Overrides:
      collectImports in class Flux
      Parameters:
      collectedImports - a set to be filled by the used imports