Apache Solr open-source search software
LUCENE-5432: Fix EliasFanoEncoder's number of bits per index entry.
Adrien Grandf0d4dd22528a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex ebe7bb12a8a..12c4dea136b 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -92,6 +92,9 @@ Bug fixesNullPointerException, if the synonym map is empty when creatingSynonymFilter (帅广应 via Mike McCandless)+* LUCENE-5432: EliasFanoDocIdSet: Fix number of index entry bits when the maximum+ entry is a power of 2. (Paul Elschot via Adrien Grand)+Test Framework* LUCENE-5449: Rename _TestUtil and _TestHelper to remove the leading _.diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java b/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.javaindex d55dd632af9..1079bf5be30 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java@@ -177,7 +177,7 @@ public class EliasFanoEncoder {this.numIndexEntries = (nIndexEntries >= 0) ? nIndexEntries : 0;long maxIndexEntry = maxHighValue + numValues - 1; // clear upper bits, set upper bits, start at zerothis.nIndexEntryBits = (maxIndexEntry <= 0) ? 0- : (64 - Long.numberOfLeadingZeros(maxIndexEntry - 1));+ : (64 - Long.numberOfLeadingZeros(maxIndexEntry));long numLongsForIndexBits = numLongsForBits(numIndexEntries * nIndexEntryBits);if (numLongsForIndexBits > Integer.MAX_VALUE) {throw new IllegalArgumentException("numLongsForIndexBits too large to index a long array: " + numLongsForIndexBits);