Creates an instance of ``CommonBehavior``, which contains a basic configuration of a behavior of temporal operators (like ``windowby`` or ``asof_join``). Each temporal operator tracks its own time (defined as a maximum time that arrived to the operator) and this configuration tells it th
(
delay: IntervalType | None = None,
cutoff: IntervalType | None = None,
keep_results: bool = True,
)
| 27 | |
| 28 | |
| 29 | def common_behavior( |
| 30 | delay: IntervalType | None = None, |
| 31 | cutoff: IntervalType | None = None, |
| 32 | keep_results: bool = True, |
| 33 | ) -> CommonBehavior: |
| 34 | """Creates an instance of ``CommonBehavior``, which contains a basic configuration of |
| 35 | a behavior of temporal operators (like ``windowby`` or ``asof_join``). |
| 36 | Each temporal operator tracks its own time (defined as a maximum time that arrived to |
| 37 | the operator) and this configuration tells it that some of its inputs or outputs may |
| 38 | be delayed or ignored. |
| 39 | The decisions are based on the current time of the operator and the time associated |
| 40 | with an input/output entry. Additionally, it allows the operator to free up memory by |
| 41 | removing parts of internal state that cannot interact with any future input entries. |
| 42 | |
| 43 | Remark: for the sake of temporal behavior, the current time of each operator is |
| 44 | updated only after it processes all the data that arrived on input. In other words, |
| 45 | if several new input entries arrived to the system simultaneously, each of those |
| 46 | entries will be processed using last recorded time, and the recorded time is upda |
| 47 | |
| 48 | Args: |
| 49 | delay: |
| 50 | Optional. |
| 51 | |
| 52 | For windows, delays initial output by ``delay`` with respect to the |
| 53 | beginning of the window. Setting it to ``None`` does not enable |
| 54 | delaying mechanism. |
| 55 | |
| 56 | For interval joins and asof joins, it delays the time the record is joined by ``delay``. |
| 57 | |
| 58 | Using `delay` is useful when updates are too frequent. |
| 59 | cutoff: |
| 60 | Optional. |
| 61 | |
| 62 | For windows, stops updating windows which end earlier than maximal |
| 63 | seen time minus ``cutoff``. Setting cutoff to ``None`` does not enable |
| 64 | cutoff mechanism. |
| 65 | |
| 66 | For interval joins and asof joins, it ignores entries that are older |
| 67 | than maximal seen time minus ``cutoff``. This parameter is also used to clear |
| 68 | memory. It allows to release memory used by entries that won't change. |
| 69 | |
| 70 | keep_results: If set to True, keeps all results of the operator. If set to False, |
| 71 | keeps only results that are newer than maximal seen time minus ``cutoff``. |
| 72 | Can't be set to ``False``, when ``cutoff`` is ``None``. |
| 73 | """ |
| 74 | assert not (cutoff is None and not keep_results) |
| 75 | return CommonBehavior(delay, cutoff, keep_results) |
| 76 | |
| 77 | |
| 78 | @dataclass |