RollingGroup
RollingGroup
calculates a window-based rolling group in an updateBy
table operation. The rolling group can be calculated using forward and/or backward windows.
Syntax
RollingGroup(revTicks, fwdTicks, pairs)
RollingGroup(revTicks, pairs)
RollingGroup(timestampCol, revTime, fwdTime, pairs)
RollingGroup(timestampCol, revTime, pairs)
RollingGroup(timestampCol, revDuration, pairs)
RollingGroup(timestampCol, revDuration, fwdDuration, pairs)
Parameters
Parameter | Type | Description |
---|---|---|
revTicks | long | The look-behind window size in ticks (rows). If positive, it defines the maximum number of rows before the current row that will be used. If negative, it defines the minimum number of rows after the current row that will be used. |
fwdTicks | long | The look-forward window size in ticks (rows). If positive, it defines the maximum number of rows after the current row that will be used. If negative, it defines the minimum number of rows before the current row that will be used. |
pairs | String... | The input/output column name pairs. |
timestampCol | String | The name of the timestamp column. |
revDuration | Duration | The look-behind window size in Duration. |
fwdDuration | Duration | The look-forward window size in Duration. |
revTime | long | The look-behind window size in nanoseconds. |
fwdTime | long | The look-forward window size in nanoseconds. |
Returns
An UpdateByOperation
to be used in an updateBy
table operation.
Examples
The following example performs an updateBy
on the source
table using four row-based RollingGroup
operations. Each operation uses different revTicks
and fwdTicks
values to show how they affect the output. Note that the first operation calls the method using only revTicks
and the column name.
rng = new Random()
source = emptyTable(10).update("X = rng.nextInt(25)")
opRollGrp = RollingGroup(3, "RollingGroup = X")
opPrior = RollingGroup(3, -1, "WindowPrior = X")
opPosterior = RollingGroup(-1, 3, "WindowPosterior = X")
opMiddle = RollingGroup(1, 1, "WindowMiddle = X")
result = source.updateBy([opRollGrp, opPrior, opPosterior, opMiddle])
- source
- result