You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/01/29 13:32:32 UTC

svn commit: r1237263 - in /lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene: codecs/Codec.java index/SegmentInfo.java

Author: rmuir
Date: Sun Jan 29 12:32:32 2012
New Revision: 1237263

URL: http://svn.apache.org/viewvc?rev=1237263&view=rev
Log:
LUCENE-3728: SI.files() always calls Codec.files()

Modified:
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/Codec.java
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/Codec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/Codec.java?rev=1237263&r1=1237262&r2=1237263&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/Codec.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/Codec.java Sun Jan 29 12:32:32 2012
@@ -20,8 +20,10 @@ package org.apache.lucene.codecs;
 import java.io.IOException;
 import java.util.Set;
 
+import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.SegmentInfo;
 import org.apache.lucene.util.NamedSPILoader;
+import org.apache.lucene.util.StringHelper;
 import org.apache.lucene.store.CompoundFileDirectory;
 import org.apache.lucene.store.Directory;
 
@@ -48,15 +50,23 @@ public abstract class Codec implements N
    * the <code>info</code> segment.
    */
   public void files(Directory dir, SegmentInfo info, Set<String> files) throws IOException {
-    assert (dir instanceof CompoundFileDirectory) == false;
-    postingsFormat().files(dir, info, "", files);
-    storedFieldsFormat().files(dir, info, files);
-    termVectorsFormat().files(dir, info, files);
-    fieldInfosFormat().files(dir, info, files);
-    // TODO: segmentInfosFormat should be allowed to declare additional files
-    // if it wants, in addition to segments_N
-    docValuesFormat().files(dir, info, files);
-    normsFormat().files(dir, info, files);
+    if (info.getUseCompoundFile()) {
+      files.add(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION));
+      // nocommit: get this out of here: 3.x codec should override this
+      String version = info.getVersion();
+      if (version != null && StringHelper.getVersionComparator().compare("4.0", version) <= 0) {
+        files.add(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
+      }
+    } else {
+      postingsFormat().files(dir, info, "", files);
+      storedFieldsFormat().files(dir, info, files);
+      termVectorsFormat().files(dir, info, files);
+      fieldInfosFormat().files(dir, info, files);
+      // TODO: segmentInfosFormat should be allowed to declare additional files
+      // if it wants, in addition to segments_N
+      docValuesFormat().files(dir, info, files);
+      normsFormat().files(dir, info, files);
+    }
   }
   
   /** Populates <code>files</code> with any filenames that are

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1237263&r1=1237262&r2=1237263&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java Sun Jan 29 12:32:32 2012
@@ -33,7 +33,6 @@ import org.apache.lucene.store.CompoundF
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.util.Constants;
-import org.apache.lucene.util.StringHelper;
 
 /**
  * Information about a segment such as it's name, directory, and files related
@@ -473,17 +472,7 @@ public final class SegmentInfo implement
     }
     final Set<String> fileSet = new HashSet<String>();
 
-    boolean useCompoundFile = getUseCompoundFile();
-
-    if (useCompoundFile) {
-      fileSet.add(IndexFileNames.segmentFileName(name, "", IndexFileNames.COMPOUND_FILE_EXTENSION));
-      if (version != null && StringHelper.getVersionComparator().compare("4.0", version) <= 0) {
-        fileSet.add(IndexFileNames.segmentFileName(name, "",
-            IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
-      }
-    } else {
-      codec.files(dir, this, fileSet);
-    }
+    codec.files(dir, this, fileSet);
     
     // regardless of compound file setting: these files are always in the directory
     codec.separateFiles(dir, this, fileSet);