Class SeriesAggregator

java.lang.Object
org.apache.juneau.console.data.SeriesAggregator

public final class SeriesAggregator extends Object
Answers a console data source's aggregate request in one pass over a row stream.

The request names a window, a bucket unit, up to three groupBy fields and the measures to compute. Any other query parameter is an app filter, returned untouched by SeriesAggregator.Request.filters() for the app's own row query. Fields used by groupBy or a measure must be allowed with allowFields(String...). A bad request throws SeriesAggregator.RequestException (HTTP 400, E-75). At most maxBuckets(int) result cells are kept; rows that would open another cell are dropped and the result is marked truncated.

A group value is the text of the row's value, or null (JSON null) when the row has none, so a missing value and the text "null" are different groups. The null group sorts first within its bucket.

Example:

@RestGet(path="/series/aggregate") public void aggregate(RestRequest req, RestResponse res) throws Exception { var q = SeriesAggregator.Request.from(req); try (var rows = svc.rows(q.start(), q.end(), q.filters())) { SeriesAggregator.create().timeField("start") .allowFields("status", "ms") .maxBuckets(10_000).aggregate(q, rows).writeTo(res); } }

Since:
10.0.0
  • Method Details