Index: src/test/org/apache/lucene/TestExternalCodecs.java =================================================================== --- src/test/org/apache/lucene/TestExternalCodecs.java (revision 926976) +++ src/test/org/apache/lucene/TestExternalCodecs.java (working copy) @@ -478,9 +478,9 @@ * You must ensure every field you index has a Codec, or * the defaultCodec is non null. Also, the separate * codecs cannot conflict on file names.*/ - // nocommit -- promote to core + // TODO: promote to core public static class PerFieldCodecWrapper extends Codec { - private final Map fields = new HashMap(); + private final Map fields = new IdentityHashMap(); private final Codec defaultCodec; public PerFieldCodecWrapper(Codec defaultCodec) { Index: src/test/org/apache/lucene/index/FlexTestUtil.java =================================================================== --- src/test/org/apache/lucene/index/FlexTestUtil.java (revision 926976) +++ src/test/org/apache/lucene/index/FlexTestUtil.java (working copy) @@ -261,35 +261,38 @@ if (rand.nextBoolean()) { // use bulk read API termDocs.seek(t); - DocsEnum.BulkReadResult result1 = null; + DocsEnum.BulkReadResult result1 = docs.getBulkResult(); + int result1Count = 0; int count2 = 0; while(true) { - if (result1 == null || result1.count == 0) { - result1 = docs.read(); + if (result1Count == 0) { + result1Count = docs.read(); } if (count2 == 0) { count2 = termDocs.read(docs2, freqs2); } - if (result1.count == 0 || count2 == 0) { + if (result1Count == 0 || count2 == 0) { assertEquals(0, count2); - assertEquals(0, result1.count); + assertEquals(0, result1Count); break; } - final int limit = Math.min(result1.count, count2); + final int limit = Math.min(result1Count, count2); for(int i=0;i limit) { + if (result1Count > limit) { // copy down - // nocommit -- hmm in general I should - // not muck w/ the int[]'s returned to - // me like this...? - System.arraycopy(result1.docs.ints, limit, result1.docs.ints, 0, result1.count-limit); - System.arraycopy(result1.freqs.ints, limit, result1.freqs.ints, 0, result1.count-limit); + // TODO: in general I should not muck w/ + // the int[]'s returned to me like + // this... this could mess up codecs + // that have persistent RAM storage of + // these int[]'s + System.arraycopy(result1.docs.ints, limit, result1.docs.ints, 0, result1Count-limit); + System.arraycopy(result1.freqs.ints, limit, result1.freqs.ints, 0, result1Count-limit); } - result1.count -= limit; + result1Count -= limit; if (count2 > limit) { // copy down Index: src/java/org/apache/lucene/analysis/tokenattributes/CharTermAttributeImpl.java =================================================================== --- src/java/org/apache/lucene/analysis/tokenattributes/CharTermAttributeImpl.java (revision 926976) +++ src/java/org/apache/lucene/analysis/tokenattributes/CharTermAttributeImpl.java (working copy) @@ -136,7 +136,7 @@ // *** TermToBytesRefAttribute interface *** public int toBytesRef(BytesRef target) { - // nocommit: Maybe assume that bytes is already initialized? TermsHashPerField ensures this. + // TODO: Maybe require that bytes is already initialized? TermsHashPerField ensures this. if (target.bytes == null) { target.bytes = new byte[termLength * 4]; } @@ -238,7 +238,6 @@ @Override public String toString() { - // nocommit: CharSequence requires that only the contents are returned, but this is orginal code: "term=" + new String(termBuffer, 0, termLength) return new String(termBuffer, 0, termLength); } Index: src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java =================================================================== --- src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (revision 926976) +++ src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (working copy) @@ -139,11 +139,12 @@ // System.out.println(" iter termCount=" + termCount + " term=" + // enumerator.term().toBytesString()); docsEnum = termsEnum.docs(delDocs, docsEnum); + final DocsEnum.BulkReadResult result = docsEnum.getBulkResult(); while (true) { - final DocsEnum.BulkReadResult result = docsEnum.read(); - if (result.count != 0) { + final int count = docsEnum.read(); + if (count != 0) { final int[] docs = result.docs.ints; - for (int i = 0; i < result.count; i++) { + for (int i = 0; i < count; i++) { bitSet.set(docs[i]); } } else { Index: src/java/org/apache/lucene/search/TermScorer.java =================================================================== --- src/java/org/apache/lucene/search/TermScorer.java (revision 926976) +++ src/java/org/apache/lucene/search/TermScorer.java (working copy) @@ -38,6 +38,7 @@ private float[] scoreCache = new float[SCORE_CACHE_SIZE]; private int[] docs; private int[] freqs; + private final DocsEnum.BulkReadResult bulkResult; /** * Construct a TermScorer. @@ -59,6 +60,7 @@ this.docsEnum = td; this.norms = norms; this.weightValue = weight.getValue(); + bulkResult = td.getBulkResult(); for (int i = 0; i < SCORE_CACHE_SIZE; i++) scoreCache[i] = getSimilarity().tf(i) * weightValue; @@ -70,10 +72,9 @@ } private final void refillBuffer() throws IOException { - final DocsEnum.BulkReadResult result = docsEnum.read(); // refill - pointerMax = result.count; - docs = result.docs.ints; - freqs = result.freqs.ints; + pointerMax = docsEnum.read(); // refill + docs = bulkResult.docs.ints; + freqs = bulkResult.freqs.ints; } // firstDocID is ignored since nextDoc() sets 'doc' Index: src/java/org/apache/lucene/index/AllDocsEnum.java =================================================================== --- src/java/org/apache/lucene/index/AllDocsEnum.java (revision 926976) +++ src/java/org/apache/lucene/index/AllDocsEnum.java (working copy) @@ -48,8 +48,7 @@ } @Override - public BulkReadResult read() throws IOException { - initBulkResult(); + public int read() throws IOException { final int[] docs = bulkResult.docs.ints; final int[] freqs = bulkResult.freqs.ints; int i = 0; @@ -61,8 +60,7 @@ } doc++; } - bulkResult.count = i; - return bulkResult; + return i; } @Override Index: src/java/org/apache/lucene/index/SegmentReader.java =================================================================== --- src/java/org/apache/lucene/index/SegmentReader.java (revision 926976) +++ src/java/org/apache/lucene/index/SegmentReader.java (working copy) @@ -1534,13 +1534,17 @@ } private DocsEnum.BulkReadResult pendingBulkResult; + private int bulkCount; private int pendingBulk; public int read(int[] docs, int[] freqs) throws IOException { + if (any && pendingBulkResult == null) { + pendingBulkResult = docsEnum.getBulkResult(); + } if (!any) { return 0; } else if (pendingBulk > 0) { - final int left = pendingBulkResult.count - pendingBulk; + final int left = bulkCount - pendingBulk; if (docs.length >= left) { // read all pending System.arraycopy(pendingBulkResult.docs.ints, pendingBulk, docs, 0, left); @@ -1556,11 +1560,11 @@ } } else { // nothing pending - pendingBulkResult = docsEnum.read(); - if (docs.length >= pendingBulkResult.count) { - System.arraycopy(pendingBulkResult.docs.ints, 0, docs, 0, pendingBulkResult.count); - System.arraycopy(pendingBulkResult.freqs.ints, 0, freqs, 0, pendingBulkResult.count); - return pendingBulkResult.count; + bulkCount = docsEnum.read(); + if (docs.length >= bulkCount) { + System.arraycopy(pendingBulkResult.docs.ints, 0, docs, 0, bulkCount); + System.arraycopy(pendingBulkResult.freqs.ints, 0, freqs, 0, bulkCount); + return bulkCount; } else { System.arraycopy(pendingBulkResult.docs.ints, 0, docs, 0, docs.length); System.arraycopy(pendingBulkResult.freqs.ints, 0, freqs, 0, docs.length); Index: src/java/org/apache/lucene/index/DocsEnum.java =================================================================== --- src/java/org/apache/lucene/index/DocsEnum.java (revision 926976) +++ src/java/org/apache/lucene/index/DocsEnum.java (working copy) @@ -51,7 +51,6 @@ public static class BulkReadResult { public final IntsRef docs = new IntsRef(); public final IntsRef freqs = new IntsRef(); - public int count; } protected BulkReadResult bulkResult; @@ -63,21 +62,22 @@ bulkResult.freqs.ints = new int[64]; } } + + public BulkReadResult getBulkResult() { + initBulkResult(); + return bulkResult; + } /** Bulk read (docs and freqs). After this is called, - * {@link #doc} and {@link #freq} are undefined. You must - * refer to the count member of BulkResult to determine - * how many docs were loaded (the IntsRef for docs and - * freqs will not have their length set). This method - * will not return null. The end has been reached when - * .count is 0. + * {@link #doc} and {@link #freq} are undefined. This + * returns the count read, or 0 if the end is reached. + * The IntsRef for docs and freqs will not have their + * length set. * *

NOTE: the default impl simply delegates to {@link * #nextDoc}, but subclasses may do this more * efficiently. */ - // nocommit -- maybe pre-share the BulkReadResult.... hmm - public BulkReadResult read() throws IOException { - initBulkResult(); + public int read() throws IOException { int count = 0; final int[] docs = bulkResult.docs.ints; final int[] freqs = bulkResult.freqs.ints; @@ -91,7 +91,6 @@ break; } } - bulkResult.count = count; - return bulkResult; + return count; } } Index: src/java/org/apache/lucene/index/codecs/pulsing/PulsingPostingsReaderImpl.java =================================================================== --- src/java/org/apache/lucene/index/codecs/pulsing/PulsingPostingsReaderImpl.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/pulsing/PulsingPostingsReaderImpl.java (working copy) @@ -270,7 +270,7 @@ } @Override - public BulkReadResult read() { + public int read() { int i=0; // TODO: -- ob1? initBulkResult(); @@ -284,8 +284,7 @@ i++; } } - bulkResult.count = i; - return bulkResult; + return i; } @Override Index: src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java =================================================================== --- src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java (working copy) @@ -361,9 +361,8 @@ } @Override - public BulkReadResult read() throws IOException { + public int read() throws IOException { // TODO: -- switch to bulk read api in IntIndexInput - initBulkResult(); final int[] docs = bulkResult.docs.ints; final int[] freqs = bulkResult.freqs.ints; int i = 0; @@ -382,8 +381,7 @@ i++; } } - bulkResult.count = i; - return bulkResult; + return i; } @Override Index: src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReaderImpl.java =================================================================== --- src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReaderImpl.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReaderImpl.java (working copy) @@ -281,11 +281,10 @@ } @Override - public BulkReadResult read() throws IOException { + public int read() throws IOException { if (Codec.DEBUG) { Codec.debug("sdr.bulk read: ord=" + ord + " df=" + limit + " omitTF=" + omitTF + " ord=" + ord + " of " + limit + " freq.fp=" + freqIn.getFilePointer(), desc); } - initBulkResult(); final int[] docs = bulkResult.docs.ints; final int[] freqs = bulkResult.freqs.ints; int i = 0; @@ -319,8 +318,7 @@ System.out.println(" return " + i); } - bulkResult.count = i; - return bulkResult; + return i; } @Override Index: src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java =================================================================== --- src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java (working copy) @@ -41,8 +41,10 @@ public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { StandardPostingsWriter docs = new StandardPostingsWriterImpl(state); - // nocommit -- how to gracefully upgrade to a new terms - // index impl? could just make a new named codec... + // TODO: should we make the terms index more easily + // pluggable? Ie so that this codec would record which + // index impl was used, and switch on loading? + // Or... you must make a new Codec for this? StandardTermsIndexWriter indexWriter; boolean success = false; try { Index: src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java =================================================================== --- src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java (working copy) @@ -417,14 +417,13 @@ } @Override - public BulkReadResult read() throws IOException { + public int read() throws IOException { if (bulkResult == null) { initBulkResult(); bulkResult.docs.ints = new int[32]; bulkResult.freqs.ints = new int[32]; } - bulkResult.count = this.docs.read(bulkResult.docs.ints, bulkResult.freqs.ints); - return bulkResult; + return this.docs.read(bulkResult.docs.ints, bulkResult.freqs.ints); } } Index: src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java =================================================================== --- src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java (revision 926976) +++ src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java (working copy) @@ -49,7 +49,7 @@ public Reader reader() throws IOException { final int[] buffer = new int[blockSize]; final IndexInput clone = (IndexInput) in.clone(); - // nocommit -- awkward + // TODO: can this be simplified? return new Reader(clone, buffer, this.getBlockReader(clone, buffer)); } Index: src/java/org/apache/lucene/util/BytesRef.java =================================================================== --- src/java/org/apache/lucene/util/BytesRef.java (revision 926976) +++ src/java/org/apache/lucene/util/BytesRef.java (working copy) @@ -69,9 +69,10 @@ * unpaired surrogates or invalid UTF16 code units. */ public void copy(CharSequence text) { - // nocommit -- new byte[10] is waste of resources, - // it should simply allocate text.length()*4 like UnicodeUtil. - // Ideally, I would remove this here and add a null-check in UnicodeUtil. (Uwe) + // TODO: new byte[10] is waste of resources; it should + // simply allocate text.length()*4 like UnicodeUtil. + // Ideally, I would remove this here and add a + // null-check in UnicodeUtil. (Uwe) if (bytes == null) { bytes = new byte[10]; } Index: contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java =================================================================== --- contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java (revision 926976) +++ contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java (working copy) @@ -173,7 +173,7 @@ * list of deletions. */ public static class FakeDeleteIndexReader extends FilterIndexReader { - // nocommit -- implement flex api here + // TODO: switch to flex api, here OpenBitSet dels; OpenBitSet oldDels = null; @@ -205,7 +205,6 @@ if (oldDels != null) { dels.or(oldDels); } - // nocommit -- not good that this class has to do this... storeDelDocs(null); } Index: backwards/src/test/org/apache/lucene/index/TestIndexWriter.java =================================================================== --- backwards/src/test/org/apache/lucene/index/TestIndexWriter.java (revision 926976) +++ backwards/src/test/org/apache/lucene/index/TestIndexWriter.java (working copy) @@ -4338,12 +4338,6 @@ assertTrue(dir.fileExists("myrandomfile")); - // Make sure this does not copy myrandomfile: - // nocommit -- Directory.copy now copies all files -- - // how to fix? - //Directory dir2 = new RAMDirectory(dir); - //assertTrue(!dir2.fileExists("myrandomfile")); - } finally { dir.close(); _TestUtil.rmDir(indexDir);