Skip to content

Commit

Permalink
Early termination with PointValues
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Dec 8, 2024
1 parent 3eecea4 commit 5378859
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
30 changes: 15 additions & 15 deletions .idea/vcs.xml

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

10 changes: 10 additions & 0 deletions server/src/main/java/org/opensearch/common/time/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ public static Instant clampToNanosRange(Instant instant) {
return instant;
}

public static Instant clampToMillisRange(Instant instant) {
if (instant.isBefore(Instant.ofEpochMilli(Long.MIN_VALUE))) {
return Instant.ofEpochMilli(Long.MIN_VALUE);
}
if (instant.isAfter(Instant.ofEpochMilli(Long.MAX_VALUE))) {
return Instant.ofEpochMilli(Long.MAX_VALUE);
}
return instant;
}

/**
* convert a long value to a java time instant
* the long value resembles the nanoseconds since the epoch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public enum Resolution {
MILLISECONDS(CONTENT_TYPE, NumericType.DATE) {
@Override
public long convert(Instant instant) {
return instant.toEpochMilli();
return clampToValidRange(instant).toEpochMilli();
}

@Override
Expand All @@ -133,7 +133,7 @@ public Instant toInstant(long value) {

@Override
public Instant clampToValidRange(Instant instant) {
return instant;
return DateUtils.clampToMillisRange(instant);
}

@Override
Expand Down Expand Up @@ -612,6 +612,7 @@ public Relation isFieldWithinQuery(
if (isSearchable() == false && hasDocValues()) {
return Relation.INTERSECTS;
}

if (dateParser == null) {
dateParser = this.dateMathParser;
}
Expand Down

0 comments on commit 5378859

Please sign in to comment.