-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add support for getting a key set for ImmutableOpenMap #77897
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
Add support for getting a key set for ImmutableOpenMap #77897
Conversation
f41f21b
to
9d17328
Compare
Currently, we support only getting an iterator which is quite cumbersome to work with. The Streams API interacts much better with Java Collections.
9d17328
to
25c1b9e
Compare
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Pinging @elastic/es-distributed (Team:Distributed) |
@elasticmachine update branch |
server/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Artem, I would like to see this done using keySet
instead. Thanks for working on enhancing code readability.
server/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponseTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java
Outdated
Show resolved
Hide resolved
…ng(allAliases::add)" This reverts commit 9066ef6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking better!
server/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java
Outdated
Show resolved
Hide resolved
It returns ints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more important detail otherwise looking good.
server/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java
Show resolved
Hide resolved
Thank you both! |
💔 Backport failed
You can use sqren/backport to manually backport by running |
elastic#76921 added support for getting entries as a Java stream, elastic#77897 added the ability to get keys as a Set. This PR adds the values method which returns a Collection to bring the ImmutableOpenMap API closer to java.util.Map (cherry picked from commit cb73e3f)
Currently, we support only getting an iterator which is quite cumbersome to work with. Working with a set view is much better, because it bridges the iterator with
Set
.#76921 added support for getting a stream on a map's values, we can provide a similar facility for keys and simplify a lot of client code that process the map's keys in an iterative way.