Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 812850) +++ CHANGES.txt (working copy) @@ -549,6 +549,10 @@ Because of this IndexReader.isLocked() and IndexWriter.isLocked() did not work correctly. (Uwe Schindler) + * LUCENE-1899: Fix O(N^2) CPU cost when setting docIDs in order in an + OpenBitSet, due to an inefficiency in how the underlying storage is + reallocated. (Nadav Har'El via Mike McCandless) + New features * LUCENE-1411: Added expert API to open an IndexWriter on a prior Index: src/java/org/apache/lucene/util/OpenBitSet.java =================================================================== --- src/java/org/apache/lucene/util/OpenBitSet.java (revision 812850) +++ src/java/org/apache/lucene/util/OpenBitSet.java (working copy) @@ -483,7 +483,6 @@ */ public void flip(long startIndex, long endIndex) { if (endIndex <= startIndex) return; - int oldlen = wlen; int startWord = (int)(startIndex>>6); // since endIndex is one past the end, this is index of the last @@ -742,9 +741,7 @@ */ public void ensureCapacityWords(int numWords) { if (bits.length < numWords) { - long[] newBits = new long[numWords]; - System.arraycopy(bits,0,newBits,0,wlen); - bits = newBits; + bits = ArrayUtil.grow(bits, numWords); } }