lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1210314 - in /lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index: ./ codecs/ codecs/lucene40/
Date Mon, 05 Dec 2011 02:39:10 GMT
Author: rmuir
Date: Mon Dec  5 02:39:09 2011
New Revision: 1210314

URL: http://svn.apache.org/viewvc?rev=1210314&view=rev
Log:
LUCENE-3606: remove separate norms extension from indexfilenames

Modified:
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/NormsFormat.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsFormat.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsWriter.java

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexFileNames.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
Mon Dec  5 02:39:09 2011
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import java.util.regex.Pattern;
-
 import org.apache.lucene.index.codecs.Codec;  // for javadocs
 
 // TODO: put all files under codec and remove all the static extensions here
@@ -62,9 +60,6 @@ public final class IndexFileNames {
   /** Extension of deletes */
   public static final String DELETES_EXTENSION = "del";
 
-  /** Extension of separate norms */
-  public static final String SEPARATE_NORMS_EXTENSION = "s";
-
   /**
    * This array contains all filename extensions used by
    * Lucene's index files, with one exception, namely the
@@ -180,17 +175,5 @@ public final class IndexFileNames {
       filename = filename.substring(0, idx);
     }
     return filename;
-  }
-  
-  /**
-   * Returns true if the given filename ends with the separate norms file
-   * pattern: {@code SEPARATE_NORMS_EXTENSION + "[0-9]+"}.
-   */
-  public static boolean isSeparateNormsFile(String filename) {
-    int idx = filename.lastIndexOf('.');
-    if (idx == -1) return false;
-    String ext = filename.substring(idx + 1);
-    return Pattern.matches(SEPARATE_NORMS_EXTENSION + "[0-9]+", ext);
-  }
-  
+  }  
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexWriter.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexWriter.java
Mon Dec  5 02:39:09 2011
@@ -30,6 +30,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.index.DocumentsWriterPerThread.FlushedSegment;
@@ -3980,7 +3981,7 @@ public class IndexWriter implements Clos
       for (String file : files) {
         assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
                   : ".del file is not allowed in .cfs: " + file;
-        assert !IndexFileNames.isSeparateNormsFile(file) 
+        assert !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));
@@ -3991,4 +3992,18 @@ public class IndexWriter implements Clos
 
     return files;
   }
+  
+  
+  /**
+   * Returns true if the given filename ends with the separate norms file
+   * pattern: {@code SEPARATE_NORMS_EXTENSION + "[0-9]+"}.
+   * @deprecated only for asserting
+   */
+  @Deprecated
+  private static boolean isSeparateNormsFile(String filename) {
+    int idx = filename.lastIndexOf('.');
+    if (idx == -1) return false;
+    String ext = filename.substring(idx + 1);
+    return Pattern.matches("s[0-9]+", ext);
+  }
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
Mon Dec  5 02:39:09 2011
@@ -339,6 +339,7 @@ public final class SegmentInfo implement
   /**
    * @deprecated separate norms are not supported in >= 4.0
    */
+  @Deprecated
   boolean hasSeparateNorms() {
     if (normGen == null) {
       return false;
@@ -508,16 +509,12 @@ public final class SegmentInfo implement
     if (delFileName != null && (delGen >= YES || dir.fileExists(delFileName)))
{
       fileSet.add(delFileName);
     }
-   
-    // TODO: push this to codec?
+
+    // because separate norm files are unconditionally stored outside cfs,
+    // we must explicitly ask for their filenames if we might have separate norms:
+    // remove this when 3.x indexes are no longer supported
     if (normGen != null) {
-      for (Entry<Integer,Long> entry : normGen.entrySet()) {
-        long gen = entry.getValue();
-        if (gen >= YES) {
-          // Definitely a separate norm file, with generation:
-          fileSet.add(IndexFileNames.fileNameFromGeneration(name, IndexFileNames.SEPARATE_NORMS_EXTENSION
+ entry.getKey(), gen));
-        }
-      }
+      codec.normsFormat().separateFiles(dir, this, fileSet);
     }
 
     files = new ArrayList<String>(fileSet);

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/NormsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/NormsFormat.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/NormsFormat.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/NormsFormat.java
Mon Dec  5 02:39:09 2011
@@ -34,4 +34,11 @@ public abstract class NormsFormat {
   public abstract NormsReader normsReader(Directory dir, SegmentInfo info, FieldInfos fields,
IOContext context, Directory separateNormsDir) throws IOException;
   public abstract NormsWriter normsWriter(SegmentWriteState state) throws IOException;
   public abstract void files(Directory dir, SegmentInfo info, Set<String> files) throws
IOException;
+  
+  /** 
+   * Note: this should not be overridden! 
+   * @deprecated 
+   */
+  @Deprecated
+  public void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws
IOException {};
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsFormat.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsFormat.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsFormat.java
Mon Dec  5 02:39:09 2011
@@ -45,4 +45,9 @@ public class Lucene40NormsFormat extends
   public void files(Directory dir, SegmentInfo info, Set<String> files) throws IOException
{
     Lucene40NormsReader.files(dir, info, files);
   }
+
+  @Override
+  public void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws
IOException {
+    Lucene40NormsReader.separateFiles(dir, info, files);
+  }
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
Mon Dec  5 02:39:09 2011
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
@@ -132,7 +133,7 @@ public class Lucene40NormsReader extends
   
   private static String getNormFilename(String segmentName, Map<Integer,Long> normGen,
int number) {
     if (hasSeparateNorms(normGen, number)) {
-      return IndexFileNames.fileNameFromGeneration(segmentName, IndexFileNames.SEPARATE_NORMS_EXTENSION
+ number, normGen.get(number));
+      return IndexFileNames.fileNameFromGeneration(segmentName, Lucene40NormsWriter.SEPARATE_NORMS_EXTENSION
+ number, normGen.get(number));
     } else {
       // single file for all norms
       return IndexFileNames.fileNameFromGeneration(segmentName, Lucene40NormsWriter.NORMS_EXTENSION,
SegmentInfo.WITHOUT_GEN);
@@ -180,4 +181,19 @@ public class Lucene40NormsReader extends
       files.add(normsFileName);
     }
   }
+  
+  /** @deprecated */
+  @Deprecated
+  static void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws
IOException {
+    Map<Integer,Long> normGen = info.getNormGen();
+    if (normGen != null) {
+      for (Entry<Integer,Long> entry : normGen.entrySet()) {
+        long gen = entry.getValue();
+        if (gen >= SegmentInfo.YES) {
+          // Definitely a separate norm file, with generation:
+          files.add(IndexFileNames.fileNameFromGeneration(info.name, Lucene40NormsWriter.SEPARATE_NORMS_EXTENSION
+ entry.getKey(), gen));
+        }
+      }
+    }
+  }
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsWriter.java?rev=1210314&r1=1210313&r2=1210314&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsWriter.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsWriter.java
Mon Dec  5 02:39:09 2011
@@ -40,6 +40,11 @@ public class Lucene40NormsWriter extends
   /** Extension of norms file */
   static final String NORMS_EXTENSION = "nrm";
   
+  /** Extension of separate norms file
+   * @deprecated */
+  @Deprecated
+  static final String SEPARATE_NORMS_EXTENSION = "s";
+  
   public Lucene40NormsWriter(Directory directory, String segment, IOContext context) throws
IOException {
     final String normsFileName = IndexFileNames.segmentFileName(segment, "", NORMS_EXTENSION);
     boolean success = false;



Mime
View raw message