From 96576daf53923d7e5d582bac2f3619b805d81a4c Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Wed, 7 Dec 2011 23:42:23 +0000 Subject: [PATCH] LUCENE-3606: Remove nocommits git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1211708 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/SegmentReader.java | 22 +++++++++---------- .../codecs/lucene40/Lucene40NormsReader.java | 13 ++++++----- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/SegmentReader.java b/lucene/src/java/org/apache/lucene/index/SegmentReader.java index 22eb9989d6f..5e6c6fd03f0 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentReader.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentReader.java @@ -51,13 +51,13 @@ public final class SegmentReader extends IndexReader implements Cloneable { boolean hasChanges = false; private boolean liveDocsDirty = false; - // nocommit: move the whole modification stuff to IW + // TODO: remove deletions from SR private int pendingDeleteCount; private boolean rollbackHasChanges = false; private boolean rollbackDeletedDocsDirty = false; private SegmentInfo rollbackSegmentInfo; private int rollbackPendingDeleteCount; - // end nocommit + // end TODO SegmentCoreReaders core; @@ -79,7 +79,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { return get(true, si, true, termInfosIndexDivisor, context); } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR static SegmentReader getRW(SegmentInfo si, boolean doOpenStores, int termInfosIndexDivisor, IOContext context) throws CorruptIndexException, IOException { return get(false, si, doOpenStores, termInfosIndexDivisor, context); } @@ -167,7 +167,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { * @param bv BitVector to clone * @return New BitVector */ - // nocommit: remove deletions from SR + // TODO: remove deletions from SR BitVector cloneDeletedDocs(BitVector bv) { ensureOpen(); return (BitVector)bv.clone(); @@ -182,7 +182,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { } } - // nocommit: is this needed anymore by IndexWriter? + // TODO: is this needed anymore by IndexWriter? final synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException { return reopenSegment(si, true, openReadOnly); } @@ -253,7 +253,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { return clone; } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR void doCommit() throws IOException { assert hasChanges; startCommit(); @@ -268,7 +268,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { } } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR private void startCommit() { rollbackSegmentInfo = (SegmentInfo) si.clone(); rollbackHasChanges = hasChanges; @@ -276,7 +276,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { rollbackPendingDeleteCount = pendingDeleteCount; } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR private void rollbackCommit() { si.reset(rollbackSegmentInfo); hasChanges = rollbackHasChanges; @@ -284,7 +284,7 @@ public final class SegmentReader extends IndexReader implements Cloneable { pendingDeleteCount = rollbackPendingDeleteCount; } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR private synchronized void commitChanges() throws IOException { if (liveDocsDirty) { // re-write deleted si.advanceDelGen(); @@ -351,14 +351,14 @@ public final class SegmentReader extends IndexReader implements Cloneable { return liveDocs != null; } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR synchronized void deleteDocument(int docNum) throws IOException { ensureOpen(); hasChanges = true; doDelete(docNum); } - // nocommit: remove deletions from SR + // TODO: remove deletions from SR void doDelete(int docNum) { if (liveDocs == null) { liveDocs = new BitVector(maxDoc()); diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java index d2a69a52ecc..520a902fcb6 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java @@ -33,6 +33,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.IOUtils; +import org.apache.lucene.util.MapBackedSet; import org.apache.lucene.util.StringHelper; public class Lucene40NormsReader extends NormsReader { @@ -41,7 +42,7 @@ public class Lucene40NormsReader extends NormsReader { Map norms = new HashMap(); // any .nrm or .sNN files we have open at any time. // TODO: just a list, and double-close() separate norms files? - Map openFiles = new IdentityHashMap(); + Set openFiles = new MapBackedSet(new IdentityHashMap()); // points to a singleNormFile IndexInput singleNormStream; final int maxdoc; @@ -69,7 +70,7 @@ public class Lucene40NormsReader extends NormsReader { normSeek = nextNormSeek; if (singleNormStream == null) { singleNormStream = d.openInput(fileName, context); - openFiles.put(singleNormStream, Boolean.TRUE); + openFiles.add(singleNormStream); } // All norms in the .nrm file can share a single IndexInput since // they are only used in a synchronized context. @@ -77,7 +78,7 @@ public class Lucene40NormsReader extends NormsReader { normInput = singleNormStream; } else { normInput = d.openInput(fileName, context); - openFiles.put(normInput, Boolean.TRUE); + openFiles.add(normInput); // if the segment was created in 3.2 or after, we wrote the header for sure, // and don't need to do the sketchy file size check. otherwise, we check // if the size is exactly equal to maxDoc to detect a headerless file. @@ -100,13 +101,13 @@ public class Lucene40NormsReader extends NormsReader { nextNormSeek += maxdoc; // increment also if some norms are separate } } - // nocommit: change to a real check? see LUCENE-3619 + // TODO: change to a real check? see LUCENE-3619 assert singleNormStream == null || nextNormSeek == singleNormStream.length(); success = true; } finally { if (!success) { if (openFiles != null) { - IOUtils.closeWhileHandlingException(openFiles.keySet()); + IOUtils.closeWhileHandlingException(openFiles); } } } @@ -123,7 +124,7 @@ public class Lucene40NormsReader extends NormsReader { public void close() throws IOException { try { if (openFiles != null) { - IOUtils.close(openFiles.keySet()); + IOUtils.close(openFiles); } } finally { norms = null;