lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1642558 - in /lucene/dev/trunk/lucene: ./ codecs/src/java/org/apache/lucene/codecs/simpletext/ core/src/java/org/apache/lucene/codecs/ core/src/java/org/apache/lucene/codecs/compressing/ core/src/java/org/apache/lucene/codecs/lucene50/ cor...
Date Sun, 30 Nov 2014 15:58:30 GMT
Author: rmuir
Date: Sun Nov 30 15:58:29 2014
New Revision: 1642558

URL: http://svn.apache.org/r1642558
Log:
LUCENE-6082: remove abort() from codec apis

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java
    lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
    lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50SegmentInfoFormat.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumer.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingStoredFieldsFormat.java
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyStoredFieldsFormat.java
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyTermVectorsFormat.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Sun Nov 30 15:58:29 2014
@@ -227,6 +227,8 @@ API Changes
 
 * LUCENE-6068: LeafReader.fields() never returns null. (Robert Muir)
 
+* LUCENE-6082: Remove abort() from codec apis. (Robert Muir)
+
 Bug Fixes
 
 * LUCENE-5650: Enforce read-only access to any path outside the temporary

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java
(original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java
Sun Nov 30 15:58:29 2014
@@ -205,7 +205,6 @@ public class SimpleTextSegmentInfoFormat
     } finally {
       if (!success) {
         IOUtils.closeWhileHandlingException(output);
-        IOUtils.deleteFilesIgnoringExceptions(dir, segFileName);
       } else {
         output.close();
       }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
(original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
Sun Nov 30 15:58:29 2014
@@ -70,7 +70,7 @@ public class SimpleTextStoredFieldsWrite
       success = true;
     } finally {
       if (!success) {
-        abort();
+        IOUtils.closeWhileHandlingException(this);
       }
     }
   }
@@ -152,14 +152,6 @@ public class SimpleTextStoredFieldsWrite
   }
 
   @Override
-  public void abort() {
-    try {
-      close();
-    } catch (Throwable ignored) {}
-    IOUtils.deleteFilesIgnoringExceptions(directory, IndexFileNames.segmentFileName(segment,
"", FIELDS_EXTENSION));
-  }
-
-  @Override
   public void finish(FieldInfos fis, int numDocs) throws IOException {
     if (numDocsWritten != numDocs) {
       throw new RuntimeException("mergeFields produced an invalid result: docCount is " +
numDocs 

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java
(original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java
Sun Nov 30 15:58:29 2014
@@ -74,7 +74,7 @@ public class SimpleTextTermVectorsWriter
       success = true;
     } finally {
       if (!success) {
-        abort();
+        IOUtils.closeWhileHandlingException(this);
       }
     }
   }
@@ -164,14 +164,6 @@ public class SimpleTextTermVectorsWriter
   }
 
   @Override
-  public void abort() {
-    try {
-      close();
-    } catch (Throwable ignored) {}
-    IOUtils.deleteFilesIgnoringExceptions(directory, IndexFileNames.segmentFileName(segment,
"", VECTORS_EXTENSION));
-  }
-
-  @Override
   public void finish(FieldInfos fis, int numDocs) throws IOException {
     if (numDocsWritten != numDocs) {
       throw new RuntimeException("mergeVectors produced an invalid result: mergedDocs is
" + numDocs + " but vec numDocs is " + numDocsWritten + " file=" + out.toString() + "; now
aborting this merge to prevent index corruption");

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java
Sun Nov 30 15:58:29 2014
@@ -48,7 +48,8 @@ public abstract class SegmentInfoFormat 
   public abstract SegmentInfo read(Directory directory, String segmentName, byte segmentID[],
IOContext context) throws IOException;
 
   /**
-   * Write {@link SegmentInfo} data. 
+   * Write {@link SegmentInfo} data.
+   * The codec must add its SegmentInfo filename(s) to {@code info} before doing i/o. 
    * @throws IOException If an I/O error occurs
    */
   public abstract void write(Directory dir, SegmentInfo info, IOContext ioContext) throws
IOException;

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
Sun Nov 30 15:58:29 2014
@@ -60,10 +60,6 @@ public abstract class StoredFieldsWriter
 
   /** Writes a single stored field. */
   public abstract void writeField(FieldInfo info, StorableField field) throws IOException;
-
-  /** Aborts writing entirely, implementation should remove
-   *  any partially-written files, etc. */
-  public abstract void abort();
   
   /** Called before {@link #close()}, passing in the number
    *  of documents that were written. Note that this is 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
Sun Nov 30 15:58:29 2014
@@ -93,10 +93,6 @@ public abstract class TermVectorsWriter 
 
   /** Adds a term position and offsets */
   public abstract void addPosition(int position, int startOffset, int endOffset, BytesRef
payload) throws IOException;
-  
-  /** Aborts writing entirely, implementation should remove
-   *  any partially-written files, etc. */
-  public abstract void abort();
 
   /** Called before {@link #close()}, passing in the number
    *  of documents that were written. Note that this is 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsWriter.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsWriter.java
Sun Nov 30 15:58:29 2014
@@ -128,8 +128,7 @@ public final class CompressingStoredFiel
       success = true;
     } finally {
       if (!success) {
-        IOUtils.closeWhileHandlingException(indexStream);
-        abort();
+        IOUtils.closeWhileHandlingException(fieldsStream, indexStream, indexWriter);
       }
     }
   }
@@ -304,14 +303,6 @@ public final class CompressingStoredFiel
   }
 
   @Override
-  public void abort() {
-    IOUtils.closeWhileHandlingException(this);
-    IOUtils.deleteFilesIgnoringExceptions(directory,
-        IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_EXTENSION),
-        IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_INDEX_EXTENSION));
-  }
-
-  @Override
   public void finish(FieldInfos fis, int numDocs) throws IOException {
     if (numBufferedDocs > 0) {
       flush();

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java
Sun Nov 30 15:58:29 2014
@@ -248,8 +248,7 @@ public final class CompressingTermVector
       success = true;
     } finally {
       if (!success) {
-        IOUtils.closeWhileHandlingException(indexStream);
-        abort();
+        IOUtils.closeWhileHandlingException(vectorsStream, indexStream, indexWriter);
       }
     }
   }
@@ -265,14 +264,6 @@ public final class CompressingTermVector
   }
 
   @Override
-  public void abort() {
-    IOUtils.closeWhileHandlingException(this);
-    IOUtils.deleteFilesIgnoringExceptions(directory,
-        IndexFileNames.segmentFileName(segment, segmentSuffix, VECTORS_EXTENSION),
-        IndexFileNames.segmentFileName(segment, segmentSuffix, VECTORS_INDEX_EXTENSION));
-  }
-
-  @Override
   public void startDocument(int numVectorFields) throws IOException {
     curDoc = addDocData(numVectorFields);
   }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50SegmentInfoFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50SegmentInfoFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50SegmentInfoFormat.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50SegmentInfoFormat.java
Sun Nov 30 15:58:29 2014
@@ -118,7 +118,6 @@ public class Lucene50SegmentInfoFormat e
     final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene50SegmentInfoFormat.SI_EXTENSION);
     si.addFile(fileName);
 
-    boolean success = false;
     try (IndexOutput output = dir.createOutput(fileName, ioContext)) {
       CodecUtil.writeIndexHeader(output, 
                                    Lucene50SegmentInfoFormat.CODEC_NAME, 
@@ -146,12 +145,6 @@ public class Lucene50SegmentInfoFormat e
       }
       output.writeStringSet(files);
       CodecUtil.writeFooter(output);
-      success = true;
-    } finally {
-      if (!success) {
-        // TODO: are we doing this outside of the tracking wrapper? why must SIWriter cleanup
like this?
-        IOUtils.deleteFilesIgnoringExceptions(si.dir, fileName);
-      }
     }
   }
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
Sun Nov 30 15:58:29 2014
@@ -217,11 +217,7 @@ final class DefaultIndexingChain extends
 
   @Override
   public void abort() {
-    try {
-      // E.g. close any open files in the stored fields writer:
-      storedFieldsWriter.abort();
-    } catch (Throwable t) {
-    }
+    IOUtils.closeWhileHandlingException(storedFieldsWriter);
 
     try {
       // E.g. close any open files in the term vectors writer:

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumer.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumer.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumer.java
Sun Nov 30 15:58:29 2014
@@ -126,7 +126,7 @@ final class TermVectorsConsumer extends 
       super.abort();
     } finally {
       if (writer != null) {
-        writer.abort();
+        IOUtils.closeWhileHandlingException(writer);
         writer = null;
       }
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
Sun Nov 30 15:58:29 2014
@@ -84,6 +84,8 @@ public class TestCompressingStoredFields
       iw.commit();
     }
     finally {
+      // next event will cause IW to delete the old files: we use prepareCommit just as example
+      iw.prepareCommit();
       int counter = 0;
       for (String fileName : dir.listAll()) {
         if (fileName.endsWith(".fdt") || fileName.endsWith(".fdx")) {
@@ -92,7 +94,7 @@ public class TestCompressingStoredFields
       }
       // Only one .fdt and one .fdx files must have been found
       assertEquals(2, counter);
-      iw.close();
+      iw.rollback();
       dir.close();
     }
   }

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingStoredFieldsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingStoredFieldsFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingStoredFieldsFormat.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingStoredFieldsFormat.java
Sun Nov 30 15:58:29 2014
@@ -143,11 +143,6 @@ public class AssertingStoredFieldsFormat
     }
 
     @Override
-    public void abort() {
-      in.abort();
-    }
-
-    @Override
     public void finish(FieldInfos fis, int numDocs) throws IOException {
       assert docStatus == (numDocs > 0 ? Status.FINISHED : Status.UNDEFINED);
       in.finish(fis, numDocs);

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java
Sun Nov 30 15:58:29 2014
@@ -195,11 +195,6 @@ public class AssertingTermVectorsFormat 
     }
 
     @Override
-    public void abort() {
-      in.abort();
-    }
-
-    @Override
     public void finish(FieldInfos fis, int numDocs) throws IOException {
       assert docCount == numDocs;
       assert docStatus == (numDocs > 0 ? Status.FINISHED : Status.UNDEFINED);

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyStoredFieldsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyStoredFieldsFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyStoredFieldsFormat.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyStoredFieldsFormat.java
Sun Nov 30 15:58:29 2014
@@ -64,14 +64,6 @@ class CrankyStoredFieldsFormat extends S
     }
 
     @Override
-    public void abort() {
-      delegate.abort();
-      if (random.nextInt(100) == 0) {
-        throw new RuntimeException(new IOException("Fake IOException from StoredFieldsWriter.abort()"));
-      }
-    }
-
-    @Override
     public void finish(FieldInfos fis, int numDocs) throws IOException {
       if (random.nextInt(100) == 0) {
         throw new IOException("Fake IOException from StoredFieldsWriter.finish()");

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyTermVectorsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyTermVectorsFormat.java?rev=1642558&r1=1642557&r2=1642558&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyTermVectorsFormat.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyTermVectorsFormat.java
Sun Nov 30 15:58:29 2014
@@ -64,14 +64,6 @@ class CrankyTermVectorsFormat extends Te
     }
     
     @Override
-    public void abort() {
-      delegate.abort();
-      if (random.nextInt(100) == 0) {
-        throw new RuntimeException(new IOException("Fake IOException from TermVectorsWriter.abort()"));
-      }
-    }
-    
-    @Override
     public int merge(MergeState mergeState) throws IOException {
       if (random.nextInt(100) == 0) {
         throw new IOException("Fake IOException from TermVectorsWriter.merge()");



Mime
View raw message