Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join: simplify logic passed to Deferred::work #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

teskje
Copy link
Contributor

@teskje teskje commented Jun 5, 2023

Previously, the join code had to wrap the result closure into another closure to invoke Deferred::work, to deal with the fact that matches from the todo1 list had their value and diff fields swapped.

Instead of having a closure to unswap the fields, we can simply pass them to the Deferred constructor in the correct order instead. That is, the Deferred constructor should always receive the cursor/storage from input 1 first and from input 2 second. If we make this change, then a) no swapping closure is necessary, and b) the input values match the types (C1, C2) of the Deferred struct.

This PR is a backport of MaterializeInc/materialize#19667, to avoid that the implementations diverge unnecessarily. In mz_join_core, the readability improvement from this change is more pronounced than in DD.

Previously, the join code had to wrap the `result` closure into
another closure to invoke `Deferred::work`, to deal with the fact that
matches from the `todo1` list had their value and diff fields swapped.

Instead of having a closure to unswap the fields, we can simply pass
them to the `Deferred` constructor in the correct order instead. That
is, the `Deferred` constructor should always receive the cursor/storage
from input 1 first and from input 2 second. If we make this change, then
a) no swapping closure is necessary, and b) the input values match the
types (`C1`, `C2`) of the `Deferred` struct.
@teskje teskje marked this pull request as ready for review June 5, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant