TimelyDataflow / differential-dataflow

An implementation of differential dataflow using timely dataflow on Rust.
MIT License
2.58k stars 184 forks source link

Implement half-join operator #320

Closed frankmcsherry closed 3 years ago

frankmcsherry commented 3 years ago

This PR is the beginning of delta joins for partially ordered times.

Unbeknownst to most, existing delta joins using the lookup_map operator are incorrect for partially ordered times, as two updates at times t1 and t2 that are incomparable with not notice each other, and no update at join(t1, t2) will be produced, which is wrong.

The code here follows the same structure, but orders updates by a TOTAL ORDER, which should ensure that for any two different times one comes before the other (and in this case, that "other" will be responsible for their join output). The use of a total order is a bit weird, and it is possible that I have overlooked some important details. For example, it is important to hold back trace compaction a little, so that we don't accidentally compact times to a point that disrupts the total order; this is pretty easy with (outer, inner) timestamps, as (outer, inner + 1) can be compacted by advancing its outer coordinate, to the point that it appears to come after (outer + 1, inner), which would be problematic. The example show how to evade this (subtract one from each outer coordinate) but generally this is on the user to understand.

This PR also demos the code without using Alt and Neu, who existed to allow the total order "nudge" for partially ordered times. As the comparison is done using total orders here, seems like it might just be ok to skip them and monomorphize on < and <=.

No rush to merge this, and I guess it is optional anyhow so not much harm. The existing lookup_map still makes sense as a look-up operator, just not as the basis of delta joins for partially ordered times.