From 95dc749dd5292c9475205a4614f07413a7695888 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Sat, 17 Aug 2024 20:52:38 -0700 Subject: [PATCH] Assert ranges not null Signed-off-by: Finn Carroll --- .../bucket/histogram/AutoDateHistogramAggregator.java | 6 +++++- .../bucket/histogram/DateHistogramAggregator.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregator.java index f0b7ea023bcf1..9c2e31273161d 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregator.java @@ -58,6 +58,7 @@ import org.opensearch.search.aggregations.bucket.filterrewrite.FilterRewriteOptimizationContext; import org.opensearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo; import org.opensearch.search.aggregations.bucket.terms.LongKeyedBucketOrds; +import org.opensearch.search.aggregations.bucket.filterrewrite.PackedValueRanges; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; import org.opensearch.search.internal.SearchContext; @@ -202,7 +203,10 @@ protected Prepared getRoundingPrepared() { @Override protected long getOrd(int rangeIdx) { - long rangeStart = LongPoint.decodeDimension(filterRewriteOptimizationContext.getRanges().getLower(rangeIdx), 0); + PackedValueRanges ranges = filterRewriteOptimizationContext.getRanges(); + assert(ranges != null); + + long rangeStart = LongPoint.decodeDimension(ranges.getLower(rangeIdx), 0); rangeStart = this.getFieldType().convertNanosToMillis(rangeStart); long ord = getBucketOrds().add(0, getRoundingPrepared().round(rangeStart)); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java index 5710080cf5888..4ce5817fd5b38 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java @@ -51,6 +51,7 @@ import org.opensearch.search.aggregations.bucket.BucketsAggregator; import org.opensearch.search.aggregations.bucket.filterrewrite.DateHistogramAggregatorBridge; import org.opensearch.search.aggregations.bucket.filterrewrite.FilterRewriteOptimizationContext; +import org.opensearch.search.aggregations.bucket.filterrewrite.PackedValueRanges; import org.opensearch.search.aggregations.bucket.terms.LongKeyedBucketOrds; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -147,7 +148,10 @@ protected long[] processHardBounds(long[] bounds) { @Override protected long getOrd(int rangeIdx) { - long rangeStart = LongPoint.decodeDimension(filterRewriteOptimizationContext.getRanges().getLower(rangeIdx), 0); + PackedValueRanges ranges = filterRewriteOptimizationContext.getRanges(); + assert(ranges != null); + + long rangeStart = LongPoint.decodeDimension(ranges.getLower(rangeIdx), 0); rangeStart = this.getFieldType().convertNanosToMillis(rangeStart); long ord = bucketOrds.add(0, getRoundingPrepared().round(rangeStart));