Apache Solr open-source search software
use filenames and extensions from org.apache.lucene.index.IndexFileNames
Bernhard Messerb51159aedab3
diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.javaindex 13453317574..ff3ac730942 100644--- a/src/java/org/apache/lucene/index/IndexReader.java+++ b/src/java/org/apache/lucene/index/IndexReader.java@@ -54,16 +54,6 @@ import java.util.Set;*/public abstract class IndexReader {- /**- * This array contains all filename extensions used by Lucene's index files, with- * one exception, namely the extension made up from <code>.f</code> + a number.- * Also note that two of Lucene's files (<code>deletable</code> and- * <code>segments</code>) don't have any filename extension.- */- public final static String FILENAME_EXTENSIONS[] = new String[] {- "cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del",- "tvx", "tvd", "tvf", "tvp" };-public static final class FieldOption {private String option;private FieldOption() { }@@ -188,7 +178,7 @@ public abstract class IndexReader {* {@link #isCurrent()} instead.*/public static long lastModified(File directory) throws IOException {- return FSDirectory.fileModified(directory, Constants.INDEX_SEGMENTS_FILENAME);+ return FSDirectory.fileModified(directory, IndexFileNames.SEGMENTS);}/**@@ -197,7 +187,7 @@ public abstract class IndexReader {* {@link #isCurrent()} instead.*/public static long lastModified(Directory directory) throws IOException {- return directory.fileModified(Constants.INDEX_SEGMENTS_FILENAME);+ return directory.fileModified(IndexFileNames.SEGMENTS);}/**@@ -306,7 +296,7 @@ public abstract class IndexReader {* @return <code>true</code> if an index exists; <code>false</code> otherwise*/public static boolean indexExists(String directory) {- return (new File(directory, Constants.INDEX_SEGMENTS_FILENAME)).exists();+ return (new File(directory, IndexFileNames.SEGMENTS)).exists();}/**@@ -316,7 +306,7 @@ public abstract class IndexReader {* @return <code>true</code> if an index exists; <code>false</code> otherwise*/public static boolean indexExists(File directory) {- return (new File(directory, Constants.INDEX_SEGMENTS_FILENAME)).exists();+ return (new File(directory, IndexFileNames.SEGMENTS)).exists();}/**@@ -327,7 +317,7 @@ public abstract class IndexReader {* @throws IOException if there is a problem with accessing the index*/public static boolean indexExists(Directory directory) throws IOException {- return directory.fileExists(Constants.INDEX_SEGMENTS_FILENAME);+ return directory.fileExists(IndexFileNames.SEGMENTS);}/** Returns the number of documents in this index. */diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.javaindex f97272c5a78..57d3d42ffd2 100644--- a/src/java/org/apache/lucene/index/IndexWriter.java+++ b/src/java/org/apache/lucene/index/IndexWriter.java@@ -792,10 +792,10 @@ public class IndexWriter {private final Vector readDeleteableFiles() throws IOException {Vector result = new Vector();- if (!directory.fileExists(Constants.INDEX_DELETABLE_FILENAME))+ if (!directory.fileExists(IndexFileNames.DELETABLE))return result;- IndexInput input = directory.openInput(Constants.INDEX_DELETABLE_FILENAME);+ IndexInput input = directory.openInput(IndexFileNames.DELETABLE);try {for (int i = input.readInt(); i > 0; i--) // read file namesresult.addElement(input.readString());@@ -814,6 +814,6 @@ public class IndexWriter {} finally {output.close();}- directory.renameFile("deleteable.new", Constants.INDEX_DELETABLE_FILENAME);+ directory.renameFile("deleteable.new", IndexFileNames.DELETABLE);}}diff --git a/src/java/org/apache/lucene/index/SegmentInfos.java b/src/java/org/apache/lucene/index/SegmentInfos.javaindex e0feb0c4754..90383db20c4 100644--- a/src/java/org/apache/lucene/index/SegmentInfos.java+++ b/src/java/org/apache/lucene/index/SegmentInfos.java@@ -42,7 +42,7 @@ final class SegmentInfos extends Vector {public final void read(Directory directory) throws IOException {- IndexInput input = directory.openInput(Constants.INDEX_SEGMENTS_FILENAME);+ IndexInput input = directory.openInput(IndexFileNames.SEGMENTS);try {int format = input.readInt();if(format < 0){ // file contains explicit format info@@ -92,7 +92,7 @@ final class SegmentInfos extends Vector {}// install new segment info- directory.renameFile("segments.new", Constants.INDEX_SEGMENTS_FILENAME);+ directory.renameFile("segments.new", IndexFileNames.SEGMENTS);}/**@@ -108,7 +108,7 @@ final class SegmentInfos extends Vector {public static long readCurrentVersion(Directory directory)throws IOException {- IndexInput input = directory.openInput(Constants.INDEX_SEGMENTS_FILENAME);+ IndexInput input = directory.openInput(IndexFileNames.SEGMENTS);int format = 0;long version = 0;try {diff --git a/src/java/org/apache/lucene/index/SegmentMerger.java b/src/java/org/apache/lucene/index/SegmentMerger.javaindex 769d2c53f0f..cc20e818e5b 100644--- a/src/java/org/apache/lucene/index/SegmentMerger.java+++ b/src/java/org/apache/lucene/index/SegmentMerger.java@@ -43,14 +43,6 @@ final class SegmentMerger {private Vector readers = new Vector();private FieldInfos fieldInfos;- // File extensions of old-style index files- private static final String COMPOUND_EXTENSIONS[] = new String[] {- "fnm", "frq", "prx", "fdx", "fdt", "tii", "tis"- };- private static final String VECTOR_EXTENSIONS[] = new String[] {- "tvx", "tvd", "tvf"- };-/** This ctor used only by test code.** @param dir The Directory to merge the other segments into@@ -120,11 +112,11 @@ final class SegmentMerger {new CompoundFileWriter(directory, fileName);Vector files =- new Vector(COMPOUND_EXTENSIONS.length + fieldInfos.size());+ new Vector(IndexFileNames.COMPOUND_EXTENSIONS.length + fieldInfos.size());// Basic files- for (int i = 0; i < COMPOUND_EXTENSIONS.length; i++) {- files.add(segment + "." + COMPOUND_EXTENSIONS[i]);+ for (int i = 0; i < IndexFileNames.COMPOUND_EXTENSIONS.length; i++) {+ files.add(segment + "." + IndexFileNames.COMPOUND_EXTENSIONS[i]);}// Field norm files@@ -137,8 +129,8 @@ final class SegmentMerger {// Vector filesif (fieldInfos.hasVectors()) {- for (int i = 0; i < VECTOR_EXTENSIONS.length; i++) {- files.add(segment + "." + VECTOR_EXTENSIONS[i]);+ for (int i = 0; i < IndexFileNames.VECTOR_EXTENSIONS.length; i++) {+ files.add(segment + "." + IndexFileNames.VECTOR_EXTENSIONS[i]);}}diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.javaindex 1c9db9871a0..280892c2b31 100644--- a/src/java/org/apache/lucene/index/SegmentReader.java+++ b/src/java/org/apache/lucene/index/SegmentReader.java@@ -248,8 +248,8 @@ class SegmentReader extends IndexReader {Vector files() throws IOException {Vector files = new Vector(16);- for (int i = 0; i < FILENAME_EXTENSIONS.length; i++) {- String name = segment + "." + FILENAME_EXTENSIONS[i];+ for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.length; i++) {+ String name = segment + "." + IndexFileNames.INDEX_EXTENSIONS[i];if (directory().fileExists(name))files.addElement(name);}