Apache Lucene open-source search software
LUCENE-2119: add some more comments in PQ around the +1
Michael McCandlessd2bf223b21c7
diff --git a/src/java/org/apache/lucene/util/PriorityQueue.java b/src/java/org/apache/lucene/util/PriorityQueue.javaindex dff5db673f0..68188a93f67 100644--- a/src/java/org/apache/lucene/util/PriorityQueue.java+++ b/src/java/org/apache/lucene/util/PriorityQueue.java@@ -91,9 +91,14 @@ public abstract class PriorityQueue<T> {// causes a confusing NegativeArraySizeException.// Note that very likely this will simply then hit// an OOME, but at least that's more indicative to- // caller that this values is too big:+ // caller that this values is too big. We don't +1+ // in this case, but it's very unlikely in practice+ // one will actually insert this many objects into+ // the PQ:heapSize = Integer.MAX_VALUE;} else {+ // NOTE: we add +1 because all access to heap is+ // 1-based not 0-based. heap[0] is unused.heapSize = maxSize + 1;}}