Try it yourself  ·  Sum operator

Two clocks.
One stream, aligned.

Enter two sequences and the interval between consecutive elements of each (as a rational number, e.g. 2/3, or a decimal, e.g. 0.5). The operator aligns them at the combined interval Δc = min(Δ1, Δ2), pairing every tick of the faster stream with the matching tick of the slower one.

Δc = min(Δ1, Δ2)  ·  RQL: FROM core0+core1
How it works

The faster clock sets the pace

Sum joins two regular streams side by side. The result ticks as often as the faster input; each of its ticks carries the current value of both inputs.

Faster leads

The output interval is the shorter of the two, Δc = min(Δ1, Δ2). Every element of the faster stream appears exactly once, in order.

Slower holds

The slower stream is read at the matching tick, so its value repeats until its next element arrives — no interpolation, no guessing.

Exact

The matching tick is an integer floor over rational intervals. For any pair of regular intervals the pairing is the same on every run, down to the bit.

RQL in practice

The same operator, in a query

In RQL, sum is written + between two streams. Here core0 ticks every 1/10 and core1 every 1/5, so str1 ticks every 1/10.

query.rql test/IntegrationTest/simple
STORAGE 'temp'
DECLARE a INTEGER STREAM core0, 0.1 FILE 'datafile2.dat'
DECLARE b INTEGER STREAM core1, 0.2 FILE 'datafile3.dat'
SELECT str1[0]*10,str1[1]*10,str1[1]*str1[0]+20 STREAM str1 FROM core0+core1

The formal definition and proof are in the paper. See the full query, plan and output tuples on the home page.