lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1127841 - in /lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index: IndexFileNames.java SegmentMerger.java
Date Thu, 26 May 2011 09:29:57 GMT
Author: shaie
Date: Thu May 26 09:29:56 2011
New Revision: 1127841

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

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

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexFileNames.java?rev=1127841&r1=1127840&r2=1127841&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
Thu May 26 09:29:56 2011
@@ -1,5 +1,7 @@
 package org.apache.lucene.index;
 
+import java.util.regex.Pattern;
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -260,5 +262,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/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1127841&r1=1127840&r2=1127841&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
Thu May 26 09:29:56 2011
@@ -127,8 +127,8 @@ final class SegmentMerger {
     for (String file : files) {
       assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
                 : ".del file is not allowed in .cfs: " + file;
-      assert !file.substring(file.lastIndexOf('.') + 1).startsWith(IndexFileNames.SEPARATE_NORMS_EXTENSION)

-                : "separate norms file (.s*) 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