LUCENE-2300: don't pool readers on external directories when IW

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@920270 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-03-08 11:08:26 +00:00
parent d7b77b3cee
commit d3478d38fa
1 changed files with 11 additions and 3 deletions

View File

@ -477,7 +477,8 @@ public class IndexWriter implements Closeable {
assert !pooled | readerMap.get(sr.getSegmentInfo()) == sr;
// Drop caller's ref
// Drop caller's ref; for an external reader (not
// pooled), this decRef will close it
sr.decRef();
if (pooled && (drop || (!poolReaders && sr.getRefCount() == 1))) {
@ -613,7 +614,11 @@ public class IndexWriter implements Closeable {
// synchronized
// Returns a ref, which we xfer to readerMap:
sr = SegmentReader.get(false, info.dir, info, readBufferSize, doOpenStores, termsIndexDivisor);
readerMap.put(info, sr);
if (info.dir == directory) {
// Only pool if reader is not external
readerMap.put(info, sr);
}
} else {
if (doOpenStores) {
sr.openDocStores();
@ -630,7 +635,10 @@ public class IndexWriter implements Closeable {
}
// Return a ref to our caller
sr.incRef();
if (info.dir == directory) {
// Only incRef if we pooledd (reader is not external)
sr.incRef();
}
return sr;
}