Package com.influxdb.query.dsl.functions
Class ReduceFlux
java.lang.Object
com.influxdb.query.dsl.Flux
com.influxdb.query.dsl.functions.AbstractParametrizedFlux
com.influxdb.query.dsl.functions.ReduceFlux
- All Implemented Interfaces:
Expression
,HasImports
Reduce aggregates records in each table according to the reducer.
See SPEC.
Options
- fn - Function to apply to each record with a reducer object of type 'a. [(r: record, accumulator: 'a) -> 'a]
- identity - an initial value to use when creating a reducer ['a]
Example
Restrictions restriction = Restrictions.and( Restrictions.measurement().equal("cpu"), Restrictions.field().equal("usage_system"), Restrictions.tag("service").equal("app-server") ); Flux flux = Flux .from("telegraf") .filter(restriction) .range(-12L, ChronoUnit.HOURS) .reduce("{ sum: r._value + accumulator.sum }", "{sum: 0.0}"); Flux flux = Flux .from("telegraf") .filter(restriction) .range(-12L, ChronoUnit.HOURS) .reduce() .withFunction("{sum: r._value + accumulator.sum,\ncount: accumulator.count + 1.0}") .withIdentity("{sum: 0.0, count: 0.0}");
- Author:
- Jakub Bednar (24/02/2020 13:02)
-
Field Summary
Fields inherited from class com.influxdb.query.dsl.Flux
functionsParameters, imports
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
collectImports
(Set<String> collectedImports) Collects all imports of the flux.protected String
withFunction
(String function) withIdentity
(String identity) Methods inherited from class com.influxdb.query.dsl.functions.AbstractParametrizedFlux
appendActual, beforeAppendOperatorName
Methods inherited from class com.influxdb.query.dsl.Flux
addImport, aggregateWindow, aggregateWindow, arrayFrom, arrayFrom, asVariable, columns, columns, count, count, covariance, covariance, covariance, covariance, covariance, covariance, covariance, covariance, covariance, cumulativeSum, cumulativeSum, cumulativeSum, derivative, derivative, difference, difference, difference, difference, difference, difference, distinct, distinct, drop, drop, drop, drop, duplicate, duplicate, elapsed, elapsed, elapsed, elapsed, expression, fill, fill, filter, filter, first, from, from, from, function, getImports, group, groupBy, groupBy, groupBy, groupExcept, groupExcept, groupExcept, integral, integral, interpolateLinear, interpolateLinear, join, join, keep, keep, keep, keep, last, last, limit, limit, limit, map, map, max, max, mean, mean, min, min, pivot, pivot, pivot, quantile, quantile, quantile, quantile, quantile, range, range, range, range, range, range, range, reduce, reduce, rename, rename, rename, sample, sample, sample, set, set, skew, skew, sort, sort, sort, sort, sort, sort, spread, spread, stddev, stddev, sum, sum, tail, tail, tail, timeShift, timeShift, timeShift, timeShift, to, to, to, to, to, to, to, to, toBool, toDuration, toFloat, toInt, toString, toString, toString, toStringConvert, toTime, toUInt, truncateTimeColumn, union, window, window, window, window, window, window, window, withFunction, withFunctionNamed, withPipedFunction, withPropertyNamed, withPropertyNamed, withPropertyValue, withPropertyValue, withPropertyValueEscaped, yield, yield
-
Constructor Details
-
ReduceFlux
-
-
Method Details
-
operatorName
- Specified by:
operatorName
in classAbstractParametrizedFlux
- Returns:
- name of function
-
withFunction
- Parameters:
function
- Function to apply to each record. Example: "{sum: r._value + accumulator.sum}".- Returns:
- this
-
withIdentity
- Parameters:
identity
- An initial value to use when creating a reducer. Example: "{sum: 0.0}".- Returns:
- this
-
collectImports
Description copied from class:Flux
Collects all imports of the flux.- Overrides:
collectImports
in classFlux
- Parameters:
collectedImports
- a set to be filled by the used imports
-