-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add Maps.newLinkedHashMapWithExpectedSize #84054
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
Conversation
e4286b3
to
5705b66
Compare
@elasticmachine update branch |
* @param <V> the value type | ||
* @return a new pre-sized {@link LinkedHashMap} | ||
*/ | ||
public static <K, V> Map<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) { |
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.
I would recommend to keep the return type as LinkedHashMap
. No need to hide implementation as it is already in the name. This will also avoid the type casts in some use cases
keys.put("foo.date_histogram", 123L); | ||
|
||
char[] charArray = new char[IndexWriter.MAX_TERM_LENGTH]; | ||
Arrays.fill(charArray, 'a'); | ||
keys.put("bar.terms", new String(charArray)); | ||
keys.put("abc.histogram", 1.9); | ||
keys = shuffleMap(keys, Collections.emptySet()); | ||
keys = shuffleMap((LinkedHashMap<String, Object>) keys, Collections.emptySet()); |
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.
This and above type cast could be avoided. See my other comment
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/IndexerUtilsTests.java
Outdated
Show resolved
Hide resolved
@elasticmachine run elasticsearch-ci/part-1 |
Thanks Ievgen! |
* Add Maps.newLinkedHashMapWithExpectedSize * Return LinkedHashMap * Don't cast LinkedHashMap
No description provided.