lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1199815 - in /lucene/dev/branches/lucene2621/lucene/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Wed, 09 Nov 2011 16:05:22 GMT
Author: rmuir
Date: Wed Nov  9 16:05:22 2011
New Revision: 1199815

URL: http://svn.apache.org/viewvc?rev=1199815&view=rev
Log:
LUCENE-2621: move createCompoundFile out of SegmentMerger

Modified:
    lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDoc.java
    lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java

Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1199815&r1=1199814&r2=1199815&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/IndexWriter.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/IndexWriter.java
Wed Nov  9 16:05:22 2011
@@ -36,6 +36,7 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.index.DocumentsWriterPerThread.FlushedSegment;
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.MergeState.CheckAbort;
 import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.search.Query;
@@ -2542,7 +2543,7 @@ public class IndexWriter implements Clos
 
       // Now create the compound file if needed
       if (useCompoundFile) {
-        merger.createCompoundFile(IndexFileNames.segmentFileName(mergedName, "", IndexFileNames.COMPOUND_FILE_EXTENSION),
info, context);
+        createCompoundFile(directory, IndexFileNames.segmentFileName(mergedName, "", IndexFileNames.COMPOUND_FILE_EXTENSION),
MergeState.CheckAbort.NONE, info, context);
 
         // delete new non cfs files directly: they were never
         // registered with IFD
@@ -3659,7 +3660,7 @@ public class IndexWriter implements Clos
           if (infoStream != null) {
             infoStream.message("IW", "create compound file " + compoundFileName);
           }
-          merger.createCompoundFile(compoundFileName, merge.info, new IOContext(merge.getMergeInfo()));
+          createCompoundFile(directory, compoundFileName, checkAbort, merge.info, new IOContext(merge.getMergeInfo()));
           success = true;
         } catch (IOException ioe) {
           synchronized(this) {
@@ -4105,4 +4106,32 @@ public class IndexWriter implements Clos
     ensureOpen();
     return payloadProcessorProvider;
   }
+  
+  /**
+   * NOTE: this method creates a compound file for all files returned by
+   * info.files(). While, generally, this may include separate norms and
+   * deletion files, this SegmentInfo must not reference such files when this
+   * method is called, because they are not allowed within a compound file.
+   */
+  static final Collection<String> createCompoundFile(Directory directory, String fileName,
CheckAbort checkAbort, final SegmentInfo info, IOContext context)
+          throws IOException {
+
+    // Now merge all added files
+    Collection<String> files = info.files();
+    CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context,
true);
+    try {
+      for (String file : files) {
+        assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
+                  : ".del file is not allowed in .cfs: " + file;
+        assert !IndexFileNames.isSeparateNormsFile(file) 
+                  : "separate norms file (.s[0-9]+) is not allowed in .cfs: " + file;
+        directory.copy(cfsDir, file, file, context);
+        checkAbort.work(directory.fileLength(file));
+      }
+    } finally {
+      cfsDir.close();
+    }
+
+    return files;
+  }
 }

Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1199815&r1=1199814&r2=1199815&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
Wed Nov  9 16:05:22 2011
@@ -135,34 +135,6 @@ final class SegmentMerger {
     return mergeState;
   }
 
-  /**
-   * NOTE: this method creates a compound file for all files returned by
-   * info.files(). While, generally, this may include separate norms and
-   * deletion files, this SegmentInfo must not reference such files when this
-   * method is called, because they are not allowed within a compound file.
-   */
-  final Collection<String> createCompoundFile(String fileName, final SegmentInfo info,
IOContext context)
-          throws IOException {
-
-    // Now merge all added files
-    Collection<String> files = info.files();
-    CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context,
true);
-    try {
-      for (String file : files) {
-        assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
-                  : ".del file is not allowed in .cfs: " + file;
-        assert !IndexFileNames.isSeparateNormsFile(file) 
-                  : "separate norms file (.s[0-9]+) is not allowed in .cfs: " + file;
-        directory.copy(cfsDir, file, file, context);
-        mergeState.checkAbort.work(directory.fileLength(file));
-      }
-    } finally {
-      cfsDir.close();
-    }
-
-    return files;
-  }
-  
   private static void addIndexed(IndexReader reader, FieldInfos fInfos,
       Collection<String> names, boolean storeTermVectors,
       boolean storePositionWithTermVector, boolean storeOffsetWithTermVector,

Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDoc.java?rev=1199815&r1=1199814&r2=1199815&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDoc.java Wed
Nov  9 16:05:22 2011
@@ -130,13 +130,13 @@ public class TestDoc extends LuceneTestC
       printSegment(out, si2);
       writer.close();
 
-      SegmentInfo siMerge = merge(si1, si2, "merge", false);
+      SegmentInfo siMerge = merge(directory, si1, si2, "merge", false);
       printSegment(out, siMerge);
 
-      SegmentInfo siMerge2 = merge(si1, si2, "merge2", false);
+      SegmentInfo siMerge2 = merge(directory, si1, si2, "merge2", false);
       printSegment(out, siMerge2);
 
-      SegmentInfo siMerge3 = merge(siMerge, siMerge2, "merge3", false);
+      SegmentInfo siMerge3 = merge(directory, siMerge, siMerge2, "merge3", false);
       printSegment(out, siMerge3);
       
       directory.close();
@@ -164,13 +164,13 @@ public class TestDoc extends LuceneTestC
       printSegment(out, si2);
       writer.close();
 
-      siMerge = merge(si1, si2, "merge", true);
+      siMerge = merge(directory, si1, si2, "merge", true);
       printSegment(out, siMerge);
 
-      siMerge2 = merge(si1, si2, "merge2", true);
+      siMerge2 = merge(directory, si1, si2, "merge2", true);
       printSegment(out, siMerge2);
 
-      siMerge3 = merge(siMerge, siMerge2, "merge3", true);
+      siMerge3 = merge(directory, siMerge, siMerge2, "merge3", true);
       printSegment(out, siMerge3);
       
       directory.close();
@@ -193,7 +193,7 @@ public class TestDoc extends LuceneTestC
    }
 
 
-   private SegmentInfo merge(SegmentInfo si1, SegmentInfo si2, String merged, boolean useCompoundFile)
+   private SegmentInfo merge(Directory dir, SegmentInfo si1, SegmentInfo si2, String merged,
boolean useCompoundFile)
    throws Exception {
       IOContext context = newIOContext(random);
       SegmentReader r1 = SegmentReader.get(true, si1, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR,
context);
@@ -212,7 +212,7 @@ public class TestDoc extends LuceneTestC
                                                false, codec, fieldInfos);
       
       if (useCompoundFile) {
-        Collection<String> filesToDelete = merger.createCompoundFile(merged + ".cfs",
info, newIOContext(random));
+        Collection<String> filesToDelete = IndexWriter.createCompoundFile(dir, merged
+ ".cfs", MergeState.CheckAbort.NONE, info, newIOContext(random));
         info.setUseCompoundFile(true);
         for (final String fileToDelete : filesToDelete) 
           si1.dir.deleteFile(fileToDelete);

Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1199815&r1=1199814&r2=1199815&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
Wed Nov  9 16:05:22 2011
@@ -152,7 +152,7 @@ public class TestSegmentMerger extends L
     SegmentMerger sm = new SegmentMerger(InfoStream.getDefault(), dir, 1, "a", MergeState.CheckAbort.NONE,
null, null, Codec.getDefault(), newIOContext(random));
     boolean doFail = false;
     try {
-      sm.createCompoundFile("b1", w.segmentInfos.info(0), newIOContext(random));
+      IndexWriter.createCompoundFile(dir, "b1", MergeState.CheckAbort.NONE, w.segmentInfos.info(0),
newIOContext(random));
       doFail = true; // should never get here
     } catch (AssertionError e) {
       // expected
@@ -173,7 +173,7 @@ public class TestSegmentMerger extends L
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
     try {
-      sm.createCompoundFile("b2", sis.info(0), newIOContext(random));
+      IndexWriter.createCompoundFile(dir, "b2", MergeState.CheckAbort.NONE, sis.info(0),
newIOContext(random));
       doFail = true; // should never get here
     } catch (AssertionError e) {
       // expected



Mime
View raw message