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

Remove redundant writeList from StreamOutput #98971

Merged

Conversation

original-brownbear
Copy link
Member

Noticed this when benchmarking FieldCaps transport messages. The writeList alias just adds more lines to the code and makes profiling more annoying to read, lets remove it.

Noticed this when benchmarking FieldCaps transport messages.
The `writeList` alias just adds more lines to the code and makes
profiling more annoying to read, lets remove it.
@original-brownbear original-brownbear added >non-issue :Core/Infra/Core Core issues without another label labels Aug 29, 2023
@elasticsearchmachine elasticsearchmachine added Team:Core/Infra Meta label for core/infra team v8.11.0 labels Aug 29, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@thecoop
Copy link
Member

thecoop commented Aug 29, 2023

Is this sensible? writeList is a counterpart to readList, they make the read & write code balanced, removing one & not the other might be a bit confusing.

@original-brownbear
Copy link
Member Author

@thecoop but by that reasoning we'd have to add writeSet or writeImmutableList and so on as redundant methods as well.

The logic for writing is simply the same across all collections, but reading for efficiency reasons specifies what kind of collection you want to get out of it. Also, if I want to write a list, how do I decide if I want to writeList or writeCollection, it's weird to have two aliases that always mean the same thing for the same method IMO. Plus it makes profiling more bothersome.

@thecoop
Copy link
Member

thecoop commented Aug 29, 2023

Ah, I hadn't spotted we had readSet but not writeSet already. A good change then.

@original-brownbear
Copy link
Member Author

Thanks Simon!

@original-brownbear original-brownbear merged commit e4de402 into elastic:main Aug 29, 2023
@original-brownbear original-brownbear deleted the remove-write-list branch August 29, 2023 14:01
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Sep 4, 2023
The `StreamOutput` and `StreamInput` APIs are designed so that code
which serializes objects to the transport protocol aligns closely with
the corresponding deserialization code. However today
`StreamOutput#writeCollection` pairs up with a variety of methods on
`StreamInput`, including `readList`, `readSet`, and so on. These methods
are not obviously compatible with `writeCollection` unless you look at
the implementation, and that makes verifying transport protocol code
harder than it needs to be.

This commit renames these methods to `readCollectionAsList`,
`readCollectionAsSet`, and so on, to clarify that they are compatible
with `writeCollection`.

Relates elastic#98971 (comment)
@DaveCTurner
Copy link
Contributor

I think Simon's concern about the naming of these things is valid, it is confusing that the read and write methods don't align any more. But I also agree that it doesn't make sense to have writeList and writeCollection. I opened #99150 to suggest a solution.

elasticsearchmachine pushed a commit that referenced this pull request Sep 4, 2023
The `StreamOutput` and `StreamInput` APIs are designed so that code
which serializes objects to the transport protocol aligns closely with
the corresponding deserialization code. However today
`StreamOutput#writeCollection` pairs up with a variety of methods on
`StreamInput`, including `readList`, `readSet`, and so on. These methods
are not obviously compatible with `writeCollection` unless you look at
the implementation, and that makes verifying transport protocol code
harder than it needs to be.

This commit renames these methods to `readCollectionAsList`,
`readCollectionAsSet`, and so on, to clarify that they are compatible
with `writeCollection`.

Relates
#98971 (comment)
@original-brownbear original-brownbear restored the remove-write-list branch November 30, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants