Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Mar 28, 2022

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

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
@rjernst rjernst added :Search/Search Search-related issues that do not fall into other categories >refactoring v8.2.0 labels Mar 28, 2022
@rjernst rjernst requested a review from nik9000 March 28, 2022 21:33
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Mar 28, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

public static Long toLong(String stringValue, boolean coerce) {
try {
return Long.parseLong(stringValue);
return Long.valueOf(stringValue);
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

* types and checking its range.
*/
public static long objectToLong(Object value, boolean coerce) {
public static Long objectToLong(Object value, boolean coerce) {
Copy link
Member

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.

Copy link
Member Author

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rjernst
Copy link
Member Author

rjernst commented Mar 29, 2022

@nik9000 Can you take another look?

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjernst rjernst merged commit 105cdeb into elastic:master Mar 30, 2022
@rjernst rjernst deleted the hppc/long_scriptfield branch March 30, 2022 01:44
@rjernst rjernst mentioned this pull request Mar 30, 2022
43 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants