rheon.polars.stream¶
Streaming transforms of a query before a bank: targets known only after a delay, windows looking back or ahead, and series that tick at their own times.
Each function takes a LazyFrame or a DataFrame and gives back the same
kind, holding a bounded state in memory rather than the stream, before or
beside a bank. They share three rules:
Frame first, the same kind back. Chain one with Polars’ own
pipe, aslf.pipe(rp.stream.embargo, clock="t", delay=5.0).The clock settings mean what they mean on a spec.
clockandgroupread their columns as a spec does, and a clock parameter takes a duration on a temporal clock.session_gapis the one difference, aswith_windows()says. With noclock, which onlywith_windows()allows, one unit is one row.A stateful transform resumes with
load_stateandsave_state, and takeschunk_size, as a bank does.embargo()is a plain Polars query with nothing to save, and takes neither.save_checkpoint()saves the states of several stages, a bank’s among them, as one file written in full or not at all, andload_checkpoint()gives each back.
function |
what it does |
|---|---|
doubles a stream for a target known only |
|
adds formulas over the window operators of |
|
merges streams that each run in clock order into one stream in clock order, every row kept and tagged with its stream, holding one chunk of each |
|
puts series that tick at their own times on a common grid by Barndorff-Nielsen, Hansen, Lunde & Shephard’s refresh-time rule: a grid point wherever every series has ticked at least once since the last one |
|
save the states of a run’s stages, such as a grid, a window run and a bank, as one file that a crash leaves whole, old or new, and read each stage’s state back to load where it was saved |
Each streams: embargo() merges two sorted copies of the same input with
Polars’ merge_sorted, and the other three run as an operator of the Rust
core fed one chunk at a time, read as a lazy source.
- rheon.polars.stream.ROLE = '_online_role'¶
Column
embargo()adds to say which copy of a row this is.
Columns made before a bank¶
Windows over the clock as columns, targets whose values arrive late, and series that tick at their own times brought onto one clock.
Add columns of formulas over the window operators, computed over a stream in one pass. |
|
Double a stream so that each row’s target is learned |
|
Put series that tick at their own times on a common grid of refresh times. |
|
Merge streams that each run in clock order into one stream in clock order, every row kept. |
A run’s states as one file¶
The states of a run’s stages, a bank’s among them, saved as one file written in full or not at all, and each stage’s state read back.
Save the states of a run’s stages as one file, written in full or not at all. |
|
Read back the stages of a checkpoint |