Class KeepFlux

All Implemented Interfaces:
Expression, HasImports

public final class KeepFlux extends AbstractParametrizedFlux
Keep is the inverse of drop. It will return a table containing only columns that are specified, ignoring all others. Only columns in the group key that are also specified in keep will be kept in the resulting group key. See SPEC.

Options

  • columns - The list of columns that should be included in the resulting table. Cannot be used with fn. [array of strings]
  • fn - The function which takes a column name as a parameter and returns a boolean indicating whether or not the column should be included in the resulting table. Cannot be used with columns. [function(column)]

Example

 Flux flux = Flux
     .from("telegraf")
     .keep(new String[]{"_time", "_value"});

 Flux flux = Flux
     .from("telegraf")
     .keep()
         .withFunction("column =~ /*inodes/");
 
Author:
Jakub Bednar (bednar@github) (02/08/2018 11:22)
  • Constructor Details

    • KeepFlux

      public KeepFlux(@Nonnull Flux source)
  • Method Details

    • operatorName

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

      @Nonnull public KeepFlux withColumns(@Nonnull String[] columns)
      Parameters:
      columns - The list of columns that should be included in the resulting table.
      Returns:
      this
    • withColumns

      @Nonnull public KeepFlux withColumns(@Nonnull Collection<String> columns)
      Parameters:
      columns - The list of columns that should be included in the resulting table.
      Returns:
      this
    • withFunction

      @Nonnull public KeepFlux withFunction(@Nonnull String function)
      Parameters:
      function - The function which takes a column name as a parameter and returns a boolean indicating whether or not the column should be included in the resulting table.
      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