You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/10/04 21:01:39 UTC

svn commit: r1394213 - in /lucene/dev/branches/ghost_of_4456/lucene/core/src: java/org/apache/lucene/index/ java/org/apache/lucene/store/ test/org/apache/lucene/index/

Author: mikemccand
Date: Thu Oct  4 19:01:38 2012
New Revision: 1394213

URL: http://svn.apache.org/viewvc?rev=1394213&view=rev
Log:
LUCENE-4456: current state

Modified:
    lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
    lucene/dev/branches/ghost_of_4456/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=1394213&r1=1394212&r2=1394213&view=diff
==============================================================================
--- lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java Thu Oct  4 19:01:38 2012
@@ -492,6 +492,7 @@ final class DocumentsWriter {
       throws IOException {
     assert newSegment != null;
     assert newSegment.segmentInfo != null;
+    //System.out.println("FLUSH: " + newSegment.segmentInfo.info.name);
     final SegmentInfoPerCommit segInfo = indexWriter.prepareFlushedSegment(newSegment);
     final BufferedDeletes deletes = newSegment.segmentDeletes;
     if (infoStream.isEnabled("DW")) {

Modified: lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java?rev=1394213&r1=1394212&r2=1394213&view=diff
==============================================================================
--- lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java Thu Oct  4 19:01:38 2012
@@ -3257,14 +3257,17 @@ public class IndexWriter implements Clos
       deleter.deleteNewFiles(merge.info.files());
     }
 
+    // Must note the change to segmentInfos so any commits
+    // in-flight don't lose it (IFD will incRef/protect the
+    // new files we created):
+    checkpoint();
+
     // Must close before checkpoint, otherwise IFD won't be
     // able to delete the held-open files from the merge
     // readers:
     closeMergeReaders(merge, false);
 
-    // Must note the change to segmentInfos so any commits
-    // in-flight don't lose it:
-    checkpoint();
+    deleter.deletePendingFiles();
 
     if (infoStream.isEnabled("IW")) {
       infoStream.message("IW", "after commitMerge: " + segString());
@@ -3328,6 +3331,9 @@ public class IndexWriter implements Clos
       try {
         try {
           mergeInit(merge);
+          //if (merge.info != null) {
+          //System.out.println("MERGE: " + merge.info.info.name);
+          //}
 
           if (infoStream.isEnabled("IW")) {
             infoStream.message("IW", "now merge\n  merge=" + segString(merge.segments) + "\n  index=" + segString());

Modified: lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java?rev=1394213&r1=1394212&r2=1394213&view=diff
==============================================================================
--- lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java Thu Oct  4 19:01:38 2012
@@ -495,6 +495,8 @@ public final class SegmentInfos implemen
       output.writeStringStringMap(si.getDiagnostics());
       output.writeStringSet(si.files());
 
+      output.close();
+
       success = true;
     } finally {
       if (!success) {
@@ -504,8 +506,6 @@ public final class SegmentInfos implemen
         } catch (Throwable t) {
           // Suppress so we keep throwing the original exception
         }
-      } else {
-        output.close();
       }
     }
 
@@ -848,25 +848,19 @@ public final class SegmentInfos implemen
 
   final void rollbackCommit(Directory dir) {
     if (pendingSegnOutput != null) {
-      try {
-        pendingSegnOutput.close();
-      } catch (Throwable t) {
-        // Suppress so we keep throwing the original exception
-        // in our caller
-      }
+      // Suppress so we keep throwing the original exception
+      // in our caller
+      IOUtils.closeWhileHandlingException(pendingSegnOutput);
+      pendingSegnOutput = null;
 
       // Must carefully compute fileName from "generation"
       // since lastGeneration isn't incremented:
-      try {
-        final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
-                                                                              "",
-                                                                             generation);
-        dir.deleteFile(segmentFileName);
-      } catch (Throwable t) {
-        // Suppress so we keep throwing the original exception
-        // in our caller
-      }
-      pendingSegnOutput = null;
+      final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
+                                                                            "",
+                                                                           generation);
+      // Suppress so we keep throwing the original exception
+      // in our caller
+      IOUtils.deleteFilesIgnoringExceptions(dir, segmentFileName);
     }
   }
 
@@ -928,8 +922,19 @@ public final class SegmentInfos implemen
         IOUtils.closeWhileHandlingException(pendingSegnOutput);
         rollbackCommit(dir);
       } else {
-        pendingSegnOutput.close();
-        pendingSegnOutput = null;
+        success = false;
+        try {
+          pendingSegnOutput.close();
+          success = true;
+        } finally {
+          if (!success) {
+            final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
+                                                                                 "",
+                                                                                 generation);
+            IOUtils.deleteFilesIgnoringExceptions(dir, segmentFileName);
+          }
+          pendingSegnOutput = null;
+        }
       }
     }
 

Modified: lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1394213&r1=1394212&r2=1394213&view=diff
==============================================================================
--- lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (original)
+++ lucene/dev/branches/ghost_of_4456/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java Thu Oct  4 19:01:38 2012
@@ -135,6 +135,8 @@ final class CompoundFileWriter implement
     }
     IOException priorException = null;
     IndexOutput entryTableOut = null;
+    // nocommit this code should clean up after itself
+    // (remove partial .cfs/.cfe)
     try {
       if (!pendingEntries.isEmpty() || outputTaken.get()) {
         throw new IllegalStateException("CFS has pending open files");
@@ -162,6 +164,7 @@ final class CompoundFileWriter implement
 
   private static boolean assertFileLength(long expected, IndexOutput out)
       throws IOException {
+    // nocommit move this out!
     out.flush();
     assert expected == out.length() : "expected: " + expected + " was "
         + out.length();

Modified: lucene/dev/branches/ghost_of_4456/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/ghost_of_4456/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1394213&r1=1394212&r2=1394213&view=diff
==============================================================================
--- lucene/dev/branches/ghost_of_4456/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/ghost_of_4456/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Oct  4 19:01:38 2012
@@ -1039,7 +1039,7 @@ public class TestIndexWriter extends Luc
             allowInterrupt = true;
           }
         } catch (ThreadInterruptedException re) {
-          if (VERBOSE) {
+          if (true || VERBOSE) {
             System.out.println("TEST: got interrupt");
             re.printStackTrace(System.out);
           }