Class MapFlux

All Implemented Interfaces:
Expression, HasImports

public final class MapFlux extends AbstractParametrizedFlux
Applies a function to each row of the table. See SPEC.

Options

  • fn - The function to apply to each row. The return value of the function may be a single value or an object. [function(record) value]

Example

 Restrictions restriction = Restrictions.and(
     Restrictions.measurement().equal("cpu"),
     Restrictions.field().equal("usage_system"),
     Restrictions.tag("service").equal("app-server")
 );

 // Square the value
 Flux flux = Flux
     .from("telegraf")
     .filter(restriction)
     .range(-12L, ChronoUnit.HOURS)
     .map("r._value * r._value");

 // Square the value and keep the original value
 Flux flux = Flux
     .from("telegraf")
     .filter(restriction)
     .range(-12L, ChronoUnit.HOURS)
     .map("{value: r._value, value2:r._value * r._value}");
 
Author:
Jakub Bednar (bednar@github) (17/07/2018 07:48)
  • Constructor Details

    • MapFlux

      public MapFlux(@Nonnull Flux source)
  • Method Details

    • operatorName

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

      @Nonnull public MapFlux withFunction(@Nonnull String function)
      Parameters:
      function - The function for map row of table. Example: "r._value * r._value".
      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