Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Reduce duplication in event ordering lookup methods #8453

Closed
wants to merge 1 commit into from

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Oct 2, 2020

get_topological_token_for_event and get_event_ordering were doing almost the same thing: the difference was only in the format of the result (tuple vs RoomStreamOrdering).

This commit combines the two. get_event_ordering had a cache which may have been tuned so we stick with that name, but update it to return a RoomStreamOrdering for better type safety. We also put it in StreamWorkerStore rather than EventsWorkerStore since that's where all the other "ordering" methods are.

So then we have to update all the places get_topological_token_for_event was called, to call get_event_ordering instead, and we have to update all the places get_event_ordering was called (just is_event_after) to handle RoomStreamTokens intstead of tuples.

is_event_after was only called in once place and we may as well inline it.

Based on #8452.

@richvdh richvdh changed the title ### Pull Request Checklist Reduce duplication in event ordering lookup methods Oct 2, 2020
@richvdh richvdh requested a review from a team October 2, 2020 13:59
@richvdh richvdh force-pushed the rav/ordering_method_duplication branch from 1be8225 to 798373a Compare October 5, 2020 13:45
`get_topological_token_for_event` and `get_event_ordering` were doing almost
the same thing: the difference was only in the format of the result (`tuple` vs
`RoomStreamOrdering`).

This commit combines the two. `get_event_ordering` had a cache which may have
been tuned so we stick with that name, but update it to return a
`RoomStreamOrdering` for better type safety. We also put it in
`StreamWorkerStore` rather than `EventsWorkerStore` since that's where all the
other "ordering" methods are.

So then we have to update all the places `get_topological_token_for_event` was
called, to call `get_event_ordering` instead, and we have to update all the
places `get_event_ordering` was called (just `is_event_after`) to handle
`RoomStreamToken`s intstead of tuples.

`is_event_after` was only called in once place and we may as well inline it.
@richvdh richvdh force-pushed the rav/ordering_method_duplication branch from 798373a to 9a3b3da Compare October 5, 2020 13:56
)
should_update = token1 > token2
Copy link
Member

Choose a reason for hiding this comment

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

attr objects by default allow comparisons I'm assuming? (I don't see anything special in RoomStreamToken to support this.)

Copy link
Member

@erikjohnston erikjohnston Oct 5, 2020

Choose a reason for hiding this comment

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

Argh, #8439 removes this as RoomStreamTokens should not be comparable (as they'll be vector clocks in some cases).

@richvdh
Copy link
Member Author

richvdh commented Oct 5, 2020

I'm aborting this for now, since @erikjohnston is rewriting the world and it's not on the critical path for my work.

@richvdh richvdh closed this Oct 5, 2020
@richvdh richvdh deleted the rav/ordering_method_duplication branch December 1, 2020 12:33
@callahad callahad added the Z-Time-Tracked Element employees should track their time spent on this issue/PR. label Jan 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z-Time-Tracked Element employees should track their time spent on this issue/PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants