Class SampleFlux

All Implemented Interfaces:
Expression, HasImports

public final class SampleFlux extends AbstractParametrizedFlux
Sample values from a table. See SPEC.

Options

  • n - Sample every Nth element [int]
  • pos - Position offset from start of results to begin sampling. pos must be less than n. If pos less than 0, a random offset is used. Default is -1 (random offset) [int].

Example

 Flux flux = Flux.from("telegraf")
     .filter(and(measurement().equal("cpu"), field().equal("usage_system")))
     .range(-1L, ChronoUnit.DAYS)
     .sample(10);

 Flux flux = Flux.from("telegraf")
     .filter(and(measurement().equal("cpu"), field().equal("usage_system")))
     .range(-1L, ChronoUnit.DAYS)
     .sample(5, 1);
 
Author:
Jakub Bednar (bednar@github) (29/06/2018 07:25)
  • Constructor Details

    • SampleFlux

      public SampleFlux(@Nonnull Flux source)
  • Method Details

    • operatorName

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

      @Nonnull public SampleFlux withN(int n)
      Parameters:
      n - Sample every Nth element.
      Returns:
      this
    • withPos

      @Nonnull public SampleFlux withPos(int pos)
      Parameters:
      pos - Position offset from start of results to begin sampling. Must be less than @{code n}.
      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