mirror of https://github.com/apache/lucene.git
LUCENE-824: remove redundant try/catch from IndexWriter.addIndexesNoOptimize
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@515489 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b972b13174
commit
810700836f
|
@ -1169,33 +1169,26 @@ public class IndexWriter {
|
|||
|
||||
try {
|
||||
|
||||
try {
|
||||
for (int i = 0; i < dirs.length; i++) {
|
||||
if (directory == dirs[i]) {
|
||||
// cannot add this index: segments may be deleted in merge before added
|
||||
throw new IllegalArgumentException("Cannot add this index to itself");
|
||||
}
|
||||
for (int i = 0; i < dirs.length; i++) {
|
||||
if (directory == dirs[i]) {
|
||||
// cannot add this index: segments may be deleted in merge before added
|
||||
throw new IllegalArgumentException("Cannot add this index to itself");
|
||||
}
|
||||
|
||||
SegmentInfos sis = new SegmentInfos(); // read infos from dir
|
||||
sis.read(dirs[i]);
|
||||
for (int j = 0; j < sis.size(); j++) {
|
||||
SegmentInfo info = sis.info(j);
|
||||
segmentInfos.addElement(info); // add each info
|
||||
|
||||
while (startUpperBound < info.docCount) {
|
||||
startUpperBound *= mergeFactor; // find the highest level from dirs
|
||||
if (startUpperBound > maxMergeDocs) {
|
||||
// upper bound cannot exceed maxMergeDocs
|
||||
throw new IllegalArgumentException("Upper bound cannot exceed maxMergeDocs");
|
||||
}
|
||||
SegmentInfos sis = new SegmentInfos(); // read infos from dir
|
||||
sis.read(dirs[i]);
|
||||
for (int j = 0; j < sis.size(); j++) {
|
||||
SegmentInfo info = sis.info(j);
|
||||
segmentInfos.addElement(info); // add each info
|
||||
|
||||
while (startUpperBound < info.docCount) {
|
||||
startUpperBound *= mergeFactor; // find the highest level from dirs
|
||||
if (startUpperBound > maxMergeDocs) {
|
||||
// upper bound cannot exceed maxMergeDocs
|
||||
throw new IllegalArgumentException("Upper bound cannot exceed maxMergeDocs");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
for (int i = segmentInfos.size() - 1; i >= start; i--) {
|
||||
segmentInfos.remove(i);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 3 maybe merge segments starting from the highest level from dirs
|
||||
|
|
|
@ -143,6 +143,7 @@ public class TestAddIndexesNoOptimize extends TestCase {
|
|||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals(100, writer.docCount());
|
||||
assertEquals(1, writer.getSegmentCount());
|
||||
}
|
||||
|
||||
writer.setMaxMergeDocs(maxMergeDocs);
|
||||
|
|
Loading…
Reference in New Issue