From 7ca821a52f879ba4380a28e911c7150fc829b75b Mon Sep 17 00:00:00 2001 From: Michael Froh Date: Wed, 18 Dec 2024 16:49:50 -0800 Subject: [PATCH] Fix IpRangeAggregatorTests Rewrote a for-loop in BinaryRangeAggregator to be less confusing. As a side-effect, it fixed the test. Signed-off-by: Michael Froh --- .../aggregations/bucket/range/BinaryRangeAggregator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregator.java index 51c6304ef4c71..cea8cb093b95e 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregator.java @@ -202,9 +202,11 @@ abstract static class SortedSetRangeLeafCollector extends LeafBucketCollectorBas public void collect(int doc, long bucket) throws IOException { if (values.advanceExact(doc)) { int lo = 0; - int count = 0; - for (long ord = values.nextOrd(); ord != SortedSetDocValues.NO_MORE_DOCS && count < values.docValueCount(); ord = values - .nextOrd(), ++count) { + for (int i = 0; i < values.docValueCount(); i++) { + long ord = values.nextOrd(); + if (ord == SortedSetDocValues.NO_MORE_DOCS) { + break; + } lo = collect(doc, ord, bucket, lo); } }