mirror of https://github.com/apache/lucene.git
LUCENE-3143: add IndexFileNames.isSeparateNormsFile and have SegmentMerger use it
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1127848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d9fb2387be
commit
7e96774437
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue