mirror of https://github.com/apache/lucene.git
Additional Optimize Condition:
Merge a 1-segment index if compound file is used and norms have been changed by IndexReader.setNorm git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150289 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a35399734d
commit
9f5d7feafb
|
@ -347,9 +347,10 @@ public class IndexWriter {
|
||||||
while (segmentInfos.size() > 1 ||
|
while (segmentInfos.size() > 1 ||
|
||||||
(segmentInfos.size() == 1 &&
|
(segmentInfos.size() == 1 &&
|
||||||
(SegmentReader.hasDeletions(segmentInfos.info(0)) ||
|
(SegmentReader.hasDeletions(segmentInfos.info(0)) ||
|
||||||
|
segmentInfos.info(0).dir != directory ||
|
||||||
(useCompoundFile &&
|
(useCompoundFile &&
|
||||||
!SegmentReader.usesCompoundFile(segmentInfos.info(0))) ||
|
(!SegmentReader.usesCompoundFile(segmentInfos.info(0)) ||
|
||||||
segmentInfos.info(0).dir != directory))) {
|
SegmentReader.hasSeparateNorms(segmentInfos.info(0))))))) {
|
||||||
int minSegment = segmentInfos.size() - mergeFactor;
|
int minSegment = segmentInfos.size() - mergeFactor;
|
||||||
mergeSegments(minSegment < 0 ? 0 : minSegment);
|
mergeSegments(minSegment < 0 ? 0 : minSegment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,17 @@ final class SegmentReader extends IndexReader {
|
||||||
return si.dir.fileExists(si.name + ".cfs");
|
return si.dir.fileExists(si.name + ".cfs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final boolean hasSeparateNorms(SegmentInfo si) throws IOException {
|
||||||
|
String[] result = si.dir.list();
|
||||||
|
String pattern = si.name + ".f";
|
||||||
|
int patternLength = pattern.length();
|
||||||
|
for(int i = 0; i < 0; i++){
|
||||||
|
if(result[i].startsWith(pattern) && Character.isDigit(result[i].charAt(patternLength)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected final void doDelete(int docNum) throws IOException {
|
protected final void doDelete(int docNum) throws IOException {
|
||||||
if (deletedDocs == null)
|
if (deletedDocs == null)
|
||||||
deletedDocs = new BitVector(maxDoc());
|
deletedDocs = new BitVector(maxDoc());
|
||||||
|
|
Loading…
Reference in New Issue