Skip to content

Commit

Permalink
Merge branch 'main' into semantic_highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi authored Dec 6, 2024
2 parents f149399 + ca09e72 commit e0d1fe5
Show file tree
Hide file tree
Showing 46 changed files with 2,563 additions and 24 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/118027.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 118027
summary: Esql compare nanos and millis
area: ES|QL
type: enhancement
issues:
- 116281
36 changes: 36 additions & 0 deletions docs/reference/esql/functions/kibana/definition/equals.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions docs/reference/esql/functions/kibana/definition/greater_than.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions docs/reference/esql/functions/kibana/definition/less_than.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions docs/reference/esql/functions/kibana/definition/not_equals.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/types/equals.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/types/greater_than.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/types/less_than.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/types/not_equals.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ tests:
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
method: test {lookup-join.LookupMessageFromIndexKeepReordered ASYNC}
issue: https://github.com/elastic/elasticsearch/issues/118151
- class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS2UnavailableRemotesIT
method: testEsqlRcs2UnavailableRemoteScenarios
issue: https://github.com/elastic/elasticsearch/issues/117419

# Examples:
#
Expand Down
31 changes: 31 additions & 0 deletions server/src/main/java/org/elasticsearch/common/time/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,37 @@ public static long toMilliSeconds(long nanoSecondsSinceEpoch) {
return nanoSecondsSinceEpoch / 1_000_000;
}

/**
* Compare an epoch nanosecond date (such as returned by {@link DateUtils#toLong}
* to an epoch millisecond date (such as returned by {@link Instant#toEpochMilli()}}.
* <p>
* NB: This function does not implement {@link java.util.Comparator} in
* order to avoid performance costs of autoboxing the input longs.
*
* @param nanos Epoch date represented as a long number of nanoseconds.
* Note that Elasticsearch does not support nanosecond dates
* before Epoch, so this number should never be negative.
* @param millis Epoch date represented as a long number of milliseconds.
* This parameter does not have to be constrained to the
* range of long nanosecond dates.
* @return -1 if the nanosecond date is before the millisecond date,
* 0 if the two dates represent the same instant,
* 1 if the nanosecond date is after the millisecond date
*/
public static int compareNanosToMillis(long nanos, long millis) {
assert nanos >= 0;
if (millis < 0) {
return 1;
}
if (millis > MAX_NANOSECOND_IN_MILLIS) {
return -1;
}
// This can't overflow, because we know millis is between 0 and MAX_NANOSECOND_IN_MILLIS,
// and MAX_NANOSECOND_IN_MILLIS * 1_000_000 doesn't overflow.
long diff = nanos - (millis * 1_000_000);
return diff == 0 ? 0 : diff < 0 ? -1 : 1;
}

/**
* Rounds the given utc milliseconds sicne the epoch down to the next unit millis
*
Expand Down
Loading

0 comments on commit e0d1fe5

Please sign in to comment.