RangeScanner
RangeScanner
The RangeScanner is a sequencer block that allows to scan value ranges (like timestamp ranges) sequentially, not missing any value. It does this by requesting new spans (or sub-ranges), one by one, emitting the next span event when the previous span processed event was received. Span sizes can be limited by different attributes.
The block is useful for cases when we have to process some value range but the worker block can not handle this long or large work at once (for example because the result packet is getting too big etc). Then the RangeScanner block can be used to limit the span size and continue with the next span processing only after the worker block has reported that the previous span processing was done, like is illustrated in the block diagram below:
The block will scan the range continuously, without skipping any value, with the next span starting value to be equal to the previously processed span ending value.
Events
Name | Input/Output | Description |
---|---|---|
Start | Input | Causes the block to switch to started mode and will emit Started. Block will then emit a new Range event immediately and also after every following incoming NextRange event. |
Started | Output | Will be emitted immediately after Start is received (before NextRange) |
Stop | Input | Causes the block to switch to stopped mode - i.e. it will NOT emit Range events anymore on subsequent NextRange events. It still saves the processed spans received NextRange events in the stopped mode. Will emit Stopped, after mode switched. |
Stopped | Output | Will be emitted after Stop is received |
Init | Input | Acts exactly as Stop, but will emit Inited, when done. |
Inited | Output | Will be emitted after Init is received |
NextRange | Input | Instructs the block that a range is processed and when in started mode, causes it to emit a new Range event with a span next to the one that was received. |
Range | Output | Will be emitted on Start or NextRange and contains data with new span, next after previously processed span. |
Arguments
Name | Description |
---|---|
RangeStart | Start of the span. Will be emitted with Range event. When block is in timestamp scanning mode (i.e. MinTimeSpan is not zero) then the RangeStart is expected to be in TimeUnit set time units. |
RangeEnd | End of the span. Will be expected with NextRange event and will be emitted with Range event. When block is in timestamp scanning mode (i.e. MinTimeSpan is not zero) then the RangeEnd is expected to be in TimeUnit set time units. |
Properties
Name | Special flags | Description |
---|---|---|
MaxSpan | When non-zero, sets the maximum span size (i.e. abs(RangeEnd - RangeStart) value) for Range events generated. When negative, then the range will be scanned downwards. | |
MinTimeSpan | When non-zero, switches the block to timestamp scanning mode and sets the minimum timestamp span size in seconds so that smaller spans will not be emitted with Range event. RangeEnd's greater than the current system timestamp will then never be emitted, by waiting for MinTimeSpan before emitting the next Range event. | |
LastRangeEnd | Persistent | Last LastRange, that was confirmed processed by input NextRange event. Note, that this value persists application restarts. |
IsStarted | Read-only | Will be set to true when the block is in started mode. |
TimeUnit | Sets time units for LastRangeEnd, RangeEnd and RangeStart. |
Examples
Example With Limited Span Size
The following table shows some example events in input and corresponding output for RangeScanner block with MaxSpan set to 1000 and MinTimeSpan set to 0:
Timestamp (in increasing order) | Input event (with argument values) | Output event (with argument values) |
---|---|---|
`T_1` | Init (RangeEnd=1000) | |
`T_2` | Start | Range (RangeStart=1000,RangeEnd=2000) |
`T_3` | NextRange (RangeEnd=2000) | Range (RangeStart=2000,RangeEnd=3000) |
`T_4` | NextRange (RangeEnd=3000) | Range (RangeStart=3000,RangeEnd=4000) |
`T_5` | Stop | |
`T_6` | Init (RangeEnd=4000) | |
`T_7` | Start | Range (RangeStart=4000,RangeEnd=5000) |
Example With Limited Minimum Time Size for Span
The following table shows some example events in input and corresponding output for RangeScanner block with MaxSpan set to 0 and MinTimeSpan set to 5 seconds:
Timestamp | Input event (with argument values) | Output event (with argument values) |
---|---|---|
`T_1` | Init (RangeEnd=`T_1`) | |
`T_1` + 8 sec | Start | Range (RangeStart=`T_1`, RangeEnd=`T_1` + 8 sec) |
`T_1` + 9 sec | NextRange (RangeEnd=`T_1` + 8 sec) | |
`T_1` + 13 sec | Range (RangeStart=`T_1` + 8 sec, RangeEnd=`T_1` + 13 sec) | |
`T_1` + 14 sec | NextRange (RangeEnd=`T_1` + 8 sec) | |
`T_1` + 19 sec | Range (RangeStart=`T_1` + 8 sec, RangeEnd=`T_1` + 13 sec) | |
`T_2` | Stop | |
`T_3` | Init (RangeEnd=`T_3`) | |
`T_3` + 1 sec | Start | |
`T_3` + 5 sec | Range (RangeStart=`T_3`, RangeEnd=`T_3` + 5 sec) |
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.