From 35aea56ad4820b9cbe7c15cec0e237d26f4795ac Mon Sep 17 00:00:00 2001 From: Rishabh Maurya Date: Thu, 14 Mar 2024 11:10:12 -0700 Subject: [PATCH] Avoid iterations: cooling using simulated annealing --- .../org/apache/lucene/misc/index/BPIndexReorderer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java index e34567bff48..61d9914ab77 100644 --- a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java +++ b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java @@ -472,8 +472,12 @@ public final class BPIndexReorderer { @Override public int comparePivot(int j) { - int cmp = Float.compare(pivotBias, biases[j]); - if (cmp == 0) { + int cmp = Float.compare(pivotBias-iter, biases[j]); + if (cmp > 0) { + return cmp; + } + cmp = Float.compare(pivotBias, biases[j]); + if (cmp >= 0) { // Tie break on the doc ID to preserve doc ID ordering as much as possible cmp = pivotDoc - docIDs.ints[j]; }