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

trace: define BatchReader with associated types #360

Closed

Conversation

petrosagg
Copy link
Contributor

The TraceReader trait uses associated types to define its Key, Val, Time, Diff but the BatchReader trait did not, even though they are very similar in nature. Usually the choice between associated types or generic parameters on a trait is determined by whether or not a particular type is expected to implement the same trait multiple times.

My starting point was that these two trait should at the very least be consistent with respect to their structure and either both use generic parameters or both use associated types.

All the uses in this repo (and also that I can imagine being useful) don't really need BatchReader to be polymorphic for a particular type and so I chose to change that one to make it consistent with TraceReader.

The result is quite pleasing as in many cases a lot of generic parameters are erased.

In order to keep this PR short I left the Cursor trait untouched, but I believe a similar transformation would be beneficial there too, simplifying further many type signatures.

The `TraceReader` trait uses associated types to define its `Key`,
`Val`, `Time`, `Diff` but the `BatchReader` trait did not, even though
they are very similar in nature. Usually the choice between asssociated
types or generic parameters on a trait is determined by whether or not a
particular type is expected to implement the same trait multiple times.

My starting point was that these two trait should at the very least be
consistent with respect to their structure and either both use generic
parameters or both use associated types.

All the uses in this repo (and also that I can imagine being useful)
don't really need `BatchReader` to be polymorphic for a particular type
and so I chose to change that one to make it consistent with
`TraceReader`.

The result is quite pleasing as in many cases a lot of generic
parameters are erased.

In order to keep this PR short I left the `Cursor` trait untouched, but
I believe a similar transformation would be beneficial there too,
simplifying further many type signatures.

Signed-off-by: Petros Angelatos <[email protected]>
@petrosagg
Copy link
Contributor Author

petrosagg commented May 23, 2022

superseded by #367

@petrosagg petrosagg closed this May 23, 2022
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