Skip to content

Conversation

@jorisdral
Copy link
Collaborator

We add a new unions function to the Internal module, which should eventually contain the full implementation of unions. For now, the function contains boilerplate for:

  • Checking that all input tables have the same configuration, and
  • Checking that all input tables are in the same session, and
  • Duplicating references to the table contents for each of the tables
  • Creating a new table with unioned table contents

The unioning of table contents is not yet implemented and will follow in some later set of PRs.

Copy link
Collaborator

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

I was going to say this needs to be rebased on #489 but you did that while I was in the middle of reviewing it.

Base automatically changed from jdral/n-way-unions to main December 10, 2024 17:39
@jorisdral jorisdral self-assigned this Dec 10, 2024
@jorisdral jorisdral force-pushed the jdral/n-way-unions-boilerplate branch 2 times, most recently from 9936513 to b8a040b Compare December 11, 2024 09:52
Copy link
Collaborator

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the "same session" code is wrong, but easy to fix and then I think easy to explain.

Copy link
Collaborator

@mheinzel mheinzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review, just smaller notes.

@jorisdral jorisdral force-pushed the jdral/n-way-unions-boilerplate branch 2 times, most recently from ad222ee to 44008f4 Compare December 12, 2024 16:07
Copy link
Collaborator

@mheinzel mheinzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a few minor comments.

Comment on lines +558 to +560
-- INVARIANT: a table's identifier is never changed during the lifetime of
-- the table.
, tableId :: !Word64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it even change, now that it's not in the TableState any more? Same for the session below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes, because it's a record type. There's nothing stopping us from internally constructing a Table m h -> Table m h function that changes tableId. It's a silly example, I admit :P I thought it would be at least useful to mention that we shouldn't change tableId at any point

Left (i, j) -> throwIO $ ErrUnionsSessionMismatch i j
Right sesh -> pure sesh

traceWith (sessionTracer sesh) $ TraceUnions (NE.map tableId ts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we generally trace before checking things like that session and config match. Then if the check fails, the log ends with the operation that failed.

Copy link
Collaborator Author

@jorisdral jorisdral Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is that we have no tracer until after we've checked the sessions, so before we've checked the sessions we can't do any tracing yet. We could take the first tracer we find in the set of tables, but then there is the risk that the tables' tracers belong to different sessions and then it's not guaranteed that all tables have the same tracer. What I've done is change the order of checks and tracing: check sessions, trace, check table configs. That should make the trace appear earlier than it did previously

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively: we make the user pass in a session and use that one's tracer, and then check that the passed in session is the same as the tables' sessions. But I think it's also fine how we do it now

We add a new `unions` function to the `Internal` module, which should eventually
contain the full implementation of unions. For now, the function contains
boilerplate for:

* Checking that all input tables have the same configuration, and
* Checking that all input tables are in the same session, and
* Duplicating references to the table contents for each of the tables
* Creating a new table with unioned table contents

The unioning of table contents is not yet implemented and will follow in some
later set of PRs.
We have to check table types before calling the internal `union`s
code from the public API.
@jorisdral jorisdral force-pushed the jdral/n-way-unions-boilerplate branch from 6ceb69e to cb6827e Compare December 18, 2024 09:48
@jorisdral jorisdral enabled auto-merge December 18, 2024 09:51
@jorisdral jorisdral added this pull request to the merge queue Dec 18, 2024
Merged via the queue into main with commit f52293b Dec 18, 2024
27 checks passed
@jorisdral jorisdral deleted the jdral/n-way-unions-boilerplate branch December 18, 2024 10: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.

4 participants