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 ||
|
||||
(segmentInfos.size() == 1 &&
|
||||
(SegmentReader.hasDeletions(segmentInfos.info(0)) ||
|
||||
segmentInfos.info(0).dir != directory ||
|
||||
(useCompoundFile &&
|
||||
!SegmentReader.usesCompoundFile(segmentInfos.info(0))) ||
|
||||
segmentInfos.info(0).dir != directory))) {
|
||||
(!SegmentReader.usesCompoundFile(segmentInfos.info(0)) ||
|
||||
SegmentReader.hasSeparateNorms(segmentInfos.info(0))))))) {
|
||||
int minSegment = segmentInfos.size() - mergeFactor;
|
||||
mergeSegments(minSegment < 0 ? 0 : minSegment);
|
||||
}
|
||||
|
|
|
@ -177,6 +177,17 @@ final class SegmentReader extends IndexReader {
|
|||
static final boolean usesCompoundFile(SegmentInfo si) throws IOException {
|
||||
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 {
|
||||
if (deletedDocs == null)
|
||||
|
|
Loading…
Reference in New Issue