-
Notifications
You must be signed in to change notification settings - Fork 25.3k
EQL: Use the implicit tiebreaker sort value in the search queries #72089
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
Pinging @elastic/es-ql (Team:QL) |
@elasticmachine update branch |
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.
LGTM
} | ||
// this tiebreaker is null | ||
else { | ||
// nulls are last so unless both are null (equal) | ||
// this ordinal is greater (after) then the other tiebreaker | ||
// so fall through to 1 | ||
if (o.tiebreaker == null) { | ||
return 0; | ||
return Long.valueOf(implicitTiebreaker).compareTo(Long.valueOf(o.implicitTiebreaker)); |
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.
Long.compare(implicitTieBreaker, o.implicitTiebreaker)
|
||
@Override | ||
public int hashCode() { | ||
return 35; |
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.
? Ideally should be a prime such as 31
or a relative constant such as ImplicitTiebreakerHitExtractor.class.hashCode()
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.
LGTM
|
||
Object implicitTbreaker = implicitTiebreaker.extract(hit); | ||
if (implicitTbreaker instanceof Number == false) { | ||
throw new EqlIllegalArgumentException("Expected _shard_doc/implicit tiebreaker as long but got [{}]", implicitTbreaker); |
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.
Regarding the error message, could the value be a non-long integer?
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.
@bpintea no. Always long
.
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.
Would then the instance check agains a Long
be also appropriate? (just FMI, its prolly slightly safer the way it is now)
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 leave it as is, for the reason you mentioned but also to be consistent with the approach throughout that method.
return o.tiebreaker != null ? tiebreaker.compareTo(o.tiebreaker) : -1; | ||
if (o.tiebreaker != null) { | ||
if (tiebreaker.compareTo(o.tiebreaker) == 0) { | ||
return Long.valueOf(implicitTiebreaker).compareTo(Long.valueOf(o.implicitTiebreaker)); |
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 guess Costin's longs comparison applies here as well.
…o eql_pit_tiebreaker
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.
LGTM. nice!
…astic#72089) (cherry picked from commit fa92fc4)
…astic#72089) (elastic#72288) (cherry picked from commit fa92fc4)
Following the recent addition of a default tiebreaker for PIT requests, EQL sequence queries that use
search_after
should also include in the list of its values (a timestamp and an optional EQL tiebreaker) the additional default tiebreaker value.