mirror of https://github.com/apache/lucene.git
LUCENE-5255: Make DocumentsWriter reference final in IW
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1530679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f283429ee1
commit
3904328399
|
@ -228,7 +228,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
final SegmentInfos segmentInfos; // the segments
|
final SegmentInfos segmentInfos; // the segments
|
||||||
final FieldNumbers globalFieldNumberMap;
|
final FieldNumbers globalFieldNumberMap;
|
||||||
|
|
||||||
private DocumentsWriter docWriter;
|
private final DocumentsWriter docWriter;
|
||||||
private final Queue<Event> eventQueue;
|
private final Queue<Event> eventQueue;
|
||||||
final IndexFileDeleter deleter;
|
final IndexFileDeleter deleter;
|
||||||
|
|
||||||
|
@ -1043,13 +1043,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
deleter.close();
|
deleter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by assert below
|
|
||||||
final DocumentsWriter oldWriter = docWriter;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
docWriter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (infoStream.isEnabled("IW")) {
|
if (infoStream.isEnabled("IW")) {
|
||||||
infoStream.message("IW", "at close: " + segString());
|
infoStream.message("IW", "at close: " + segString());
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1054,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
closed = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
assert oldWriter.perThreadPool.numDeactivatedThreadStates() == oldWriter.perThreadPool.getMaxThreadStates() : "" + oldWriter.perThreadPool.numDeactivatedThreadStates() + " " + oldWriter.perThreadPool.getMaxThreadStates();
|
assert docWriter.perThreadPool.numDeactivatedThreadStates() == docWriter.perThreadPool.getMaxThreadStates() : "" + docWriter.perThreadPool.numDeactivatedThreadStates() + " " + docWriter.perThreadPool.getMaxThreadStates();
|
||||||
} catch (OutOfMemoryError oom) {
|
} catch (OutOfMemoryError oom) {
|
||||||
handleOOM(oom, "closeInternal");
|
handleOOM(oom, "closeInternal");
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1096,14 +1089,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
* @see #numDocs */
|
* @see #numDocs */
|
||||||
public synchronized int maxDoc() {
|
public synchronized int maxDoc() {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
int count;
|
return docWriter.getNumDocs() + segmentInfos.totalDocCount();
|
||||||
if (docWriter != null)
|
|
||||||
count = docWriter.getNumDocs();
|
|
||||||
else
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
count += segmentInfos.totalDocCount();
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns total number of docs in this index, including
|
/** Returns total number of docs in this index, including
|
||||||
|
@ -1114,12 +1100,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
* @see #numDocs */
|
* @see #numDocs */
|
||||||
public synchronized int numDocs() {
|
public synchronized int numDocs() {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
int count;
|
int count = docWriter.getNumDocs();
|
||||||
if (docWriter != null)
|
|
||||||
count = docWriter.getNumDocs();
|
|
||||||
else
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
for (final SegmentInfoPerCommit info : segmentInfos) {
|
for (final SegmentInfoPerCommit info : segmentInfos) {
|
||||||
count += info.info.getDocCount() - numDeletedDocs(info);
|
count += info.info.getDocCount() - numDeletedDocs(info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue