Skip to main content
Version: Java (Groovy)

DownsampledWhereFilter

The DownsampledWhereFilter allows users to downsample time series data by calculating the bin intervals for values, and then using upperBin and firstBy to select the last row for each bin.

caution

The column containing the data to be binned must be sorted for the method to work.

Syntax

DownsampledWhereFilter(column, binSize)
DownsampledWhereFilter(column, binSize, order)

Parameters

ParameterTypeDescription
columnString

Instant column to use for filtering.

binSizelong

Size in nanoseconds fo the time bins. Constants like DateTimeUtils.MINUTE are often used.

orderDownsampledWhereFilter.SampleOrder

By default, this method downsamples bins by upperBin and lastBy, represented by the UPPERLAST constant. Use LOWERFIRST to change this order to lowerBin and firstBy.

DownsampledWhereFilter.SampleOrder sets the desired behavior:

  • DownsampledWhereFilter.SampleOrder.UPPERLAST - constant for upperBin/lastBy.
  • DownsampledWhereFilter.SampleOrder.LOWERFIRST - constant for lowerBin/firstBy.

Returns

A DownsampledWhereFilter that can be used in a .where clause to downsample time series rows.

Examples

import io.deephaven.engine.table.impl.select.DownsampledWhereFilter

startTime = minus(now(), parseDuration("PT1H"))

source = timeTable(startTime, "PT1S").head(100).snapshot()

F = new DownsampledWhereFilter("Timestamp", SECOND * 30, DownsampledWhereFilter.SampleOrder.LOWERFIRST)

result = source.where(F)