PstepDur:
Filter:
ddwPatterns/Classes (extension) | Streams-Patterns-Events > Patterns > Time

PstepDur
ExtensionExtension

A Pstep variant that supports lookahead

Description

Pstep and PstepDur are both "sample and hold" patterns: One value from levels is repeated until a duration from durs elapses. Then, another value is chosen and repeated for the next duration.

Pstep measures elapsed time using the thread's logical time. That is, it assumes it will be evaluated only exactly when needed, not before.

PstepDur measures time based on the input event's delta. Provided that duration keys have already been set in the event, PstepDur may be polled in advance.

NOTE: It's mandatory to prepare timing information earlier in the event pattern's processing chain. See the examples.

See PcollectFinal for an example of a lookahead filter pattern.

Class Methods

.new

Create an instance of PstepDur.

Arguments:

levels

The values (of any data type) to be sampled and held.

durs

The durations for which to hold items from levels.

repeats

How many times to repeat, after running out of either levels or durs.

tolerance

How close is "close enough" (avoids problems with floating point rounding error in repeated sums).

Examples