From 5378859f0d390cab7208ab75f8141c4eb3497eae Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Thu, 5 Dec 2024 19:43:41 -0800 Subject: [PATCH] Early termination with PointValues Signed-off-by: Prudhvi Godithi --- .idea/vcs.xml | 30 +++++++++---------- .../org/opensearch/common/time/DateUtils.java | 10 +++++++ .../index/mapper/DateFieldMapper.java | 5 ++-- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 48557884a8893..3b802c80a7487 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,20 +1,20 @@ - - - + + + - + \ No newline at end of file diff --git a/server/src/main/java/org/opensearch/common/time/DateUtils.java b/server/src/main/java/org/opensearch/common/time/DateUtils.java index 7ab395a1117e7..20ae86f837f4b 100644 --- a/server/src/main/java/org/opensearch/common/time/DateUtils.java +++ b/server/src/main/java/org/opensearch/common/time/DateUtils.java @@ -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 diff --git a/server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java index aece93b90aa18..1946ecbabb7b7 100644 --- a/server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java @@ -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 @@ -133,7 +133,7 @@ public Instant toInstant(long value) { @Override public Instant clampToValidRange(Instant instant) { - return instant; + return DateUtils.clampToMillisRange(instant); } @Override @@ -612,6 +612,7 @@ public Relation isFieldWithinQuery( if (isSearchable() == false && hasDocValues()) { return Relation.INTERSECTS; } + if (dateParser == null) { dateParser = this.dateMathParser; }