lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r515489 - in /lucene/java/trunk/src: java/org/apache/lucene/index/IndexWriter.java test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
Date Wed, 07 Mar 2007 08:32:29 GMT
Author: mikemccand
Date: Wed Mar  7 00:32:28 2007
New Revision: 515489

URL: http://svn.apache.org/viewvc?view=rev&rev=515489
Log:
LUCENE-824: remove redundant try/catch from IndexWriter.addIndexesNoOptimize

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?view=diff&rev=515489&r1=515488&r2=515489
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Wed Mar  7 00:32:28
2007
@@ -1169,33 +1169,26 @@
 
     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");
-          }
-
-          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
+      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");
+        }
 
-            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

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java?view=diff&rev=515489&r1=515488&r2=515489
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java Wed Mar
 7 00:32:28 2007
@@ -143,6 +143,7 @@
     }
     catch (IllegalArgumentException e) {
       assertEquals(100, writer.docCount());
+      assertEquals(1, writer.getSegmentCount());
     }
 
     writer.setMaxMergeDocs(maxMergeDocs);



Mime
View raw message