-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Use Set instead of LongSet in long script field #85417
Conversation
The long script field uses hppc's LongSet to store the unique values to be queried. However, this set should be relatively small. This commit changes the internals of the runtime long script field to use Set<Long>. relates elastic#84735
Pinging @elastic/es-search (Team:Search) |
try { | ||
return Long.parseLong(stringValue); | ||
return Long.valueOf(stringValue); |
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 think I'd keep the return type on this one.
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 moved this to return the boxed type so that we do not rely on the JIT to inline+elide this boxing. Otherwise we would parse into a primitive long
, then need to box when actually inserting into the set. I don't feel strongly about this, though.
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 thought about it more, and I changed back to primitive.
@@ -1098,7 +1098,7 @@ public static double objectToDouble(Object value) { | |||
* Converts an Object to a {@code long} by checking it against known | |||
* types and checking its range. | |||
*/ | |||
public static long objectToLong(Object value, boolean coerce) { | |||
public static Long objectToLong(Object value, boolean coerce) { |
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'd probably keep the return type on this one too.
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.
Changed back to primitive.
assertThat(Numbers.toLong("9223372036854775807.00", true), equalTo(9223372036854775807L)); | ||
assertThat(Numbers.toLong("-9223372036854775808.00", true), equalTo(-9223372036854775808L)); | ||
assertThat(Numbers.toLong("9223372036854775807.99", true), equalTo(9223372036854775807L)); | ||
assertThat(Numbers.toLong("-9223372036854775808.99", true), equalTo(-9223372036854775808L)); |
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.
👍
@nik9000 Can you take another look? |
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.
⛵
The long script field uses hppc's LongSet to store the unique values
to be queried. However, this set should be relatively small. This commit
changes the internals of the runtime long script field to use Set.
relates #84735