lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1127848 - in /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index: IndexFileNames.java SegmentMerger.java
Date Thu, 26 May 2011 09:44:12 GMT
Author: shaie
Date: Thu May 26 09:44:12 2011
New Revision: 1127848

URL: http://svn.apache.org/viewvc?rev=1127848&view=rev
Log:
LUCENE-3143: add IndexFileNames.isSeparateNormsFile and have SegmentMerger use it

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexFileNames.java?rev=1127848&r1=1127847&r2=1127848&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexFileNames.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexFileNames.java Thu May 26
09:44:12 2011
@@ -17,6 +17,8 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
+import java.util.regex.Pattern;
+
 import org.apache.lucene.index.codecs.Codec;  // for javadocs
 
 /**
@@ -238,5 +240,16 @@ public final class IndexFileNames {
     }
     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/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1127848&r1=1127847&r2=1127848&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java Thu May 26
09:44:12 2011
@@ -135,8 +135,8 @@ final class SegmentMerger {
     for (String file : files) {
       assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
                 : ".del file is not allowed in .cfs: " + file;
-      assert !Pattern.matches("^.+[.]" + IndexFileNames.SEPARATE_NORMS_EXTENSION  + "\\d+$",
file) 
-                : "separate norms file (.s[0-9]*) is not allowed in .cfs: " + file;
+      assert !IndexFileNames.isSeparateNormsFile(file) 
+                : "separate norms file (.s[0-9]+) is not allowed in .cfs: " + file;
       cfsWriter.addFile(file);
     }
 



Mime
View raw message