Skip to content

Commit

Permalink
Assert ranges not null
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 18, 2024
1 parent 9bfa23a commit 95dc749
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 95dc749

Please sign in to comment.