mirror of https://github.com/apache/lucene.git
use filenames and extensions from org.apache.lucene.index.IndexFileNames
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@189794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba8ed654fd
commit
b51159aeda
|
@ -54,16 +54,6 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public abstract class IndexReader {
|
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 {
|
public static final class FieldOption {
|
||||||
private String option;
|
private String option;
|
||||||
private FieldOption() { }
|
private FieldOption() { }
|
||||||
|
@ -188,7 +178,7 @@ public abstract class IndexReader {
|
||||||
* {@link #isCurrent()} instead.
|
* {@link #isCurrent()} instead.
|
||||||
*/
|
*/
|
||||||
public static long lastModified(File directory) throws IOException {
|
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.
|
* {@link #isCurrent()} instead.
|
||||||
*/
|
*/
|
||||||
public static long lastModified(Directory directory) throws IOException {
|
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
|
* @return <code>true</code> if an index exists; <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean indexExists(String directory) {
|
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
|
* @return <code>true</code> if an index exists; <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean indexExists(File directory) {
|
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
|
* @throws IOException if there is a problem with accessing the index
|
||||||
*/
|
*/
|
||||||
public static boolean indexExists(Directory directory) throws IOException {
|
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. */
|
/** Returns the number of documents in this index. */
|
||||||
|
|
|
@ -792,10 +792,10 @@ public class IndexWriter {
|
||||||
|
|
||||||
private final Vector readDeleteableFiles() throws IOException {
|
private final Vector readDeleteableFiles() throws IOException {
|
||||||
Vector result = new Vector();
|
Vector result = new Vector();
|
||||||
if (!directory.fileExists(Constants.INDEX_DELETABLE_FILENAME))
|
if (!directory.fileExists(IndexFileNames.DELETABLE))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
IndexInput input = directory.openInput(Constants.INDEX_DELETABLE_FILENAME);
|
IndexInput input = directory.openInput(IndexFileNames.DELETABLE);
|
||||||
try {
|
try {
|
||||||
for (int i = input.readInt(); i > 0; i--) // read file names
|
for (int i = input.readInt(); i > 0; i--) // read file names
|
||||||
result.addElement(input.readString());
|
result.addElement(input.readString());
|
||||||
|
@ -814,6 +814,6 @@ public class IndexWriter {
|
||||||
} finally {
|
} finally {
|
||||||
output.close();
|
output.close();
|
||||||
}
|
}
|
||||||
directory.renameFile("deleteable.new", Constants.INDEX_DELETABLE_FILENAME);
|
directory.renameFile("deleteable.new", IndexFileNames.DELETABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ final class SegmentInfos extends Vector {
|
||||||
|
|
||||||
public final void read(Directory directory) throws IOException {
|
public final void read(Directory directory) throws IOException {
|
||||||
|
|
||||||
IndexInput input = directory.openInput(Constants.INDEX_SEGMENTS_FILENAME);
|
IndexInput input = directory.openInput(IndexFileNames.SEGMENTS);
|
||||||
try {
|
try {
|
||||||
int format = input.readInt();
|
int format = input.readInt();
|
||||||
if(format < 0){ // file contains explicit format info
|
if(format < 0){ // file contains explicit format info
|
||||||
|
@ -92,7 +92,7 @@ final class SegmentInfos extends Vector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// install new segment info
|
// 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)
|
public static long readCurrentVersion(Directory directory)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
IndexInput input = directory.openInput(Constants.INDEX_SEGMENTS_FILENAME);
|
IndexInput input = directory.openInput(IndexFileNames.SEGMENTS);
|
||||||
int format = 0;
|
int format = 0;
|
||||||
long version = 0;
|
long version = 0;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -43,14 +43,6 @@ final class SegmentMerger {
|
||||||
private Vector readers = new Vector();
|
private Vector readers = new Vector();
|
||||||
private FieldInfos fieldInfos;
|
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.
|
/** This ctor used only by test code.
|
||||||
*
|
*
|
||||||
* @param dir The Directory to merge the other segments into
|
* @param dir The Directory to merge the other segments into
|
||||||
|
@ -120,11 +112,11 @@ final class SegmentMerger {
|
||||||
new CompoundFileWriter(directory, fileName);
|
new CompoundFileWriter(directory, fileName);
|
||||||
|
|
||||||
Vector files =
|
Vector files =
|
||||||
new Vector(COMPOUND_EXTENSIONS.length + fieldInfos.size());
|
new Vector(IndexFileNames.COMPOUND_EXTENSIONS.length + fieldInfos.size());
|
||||||
|
|
||||||
// Basic files
|
// Basic files
|
||||||
for (int i = 0; i < COMPOUND_EXTENSIONS.length; i++) {
|
for (int i = 0; i < IndexFileNames.COMPOUND_EXTENSIONS.length; i++) {
|
||||||
files.add(segment + "." + COMPOUND_EXTENSIONS[i]);
|
files.add(segment + "." + IndexFileNames.COMPOUND_EXTENSIONS[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field norm files
|
// Field norm files
|
||||||
|
@ -137,8 +129,8 @@ final class SegmentMerger {
|
||||||
|
|
||||||
// Vector files
|
// Vector files
|
||||||
if (fieldInfos.hasVectors()) {
|
if (fieldInfos.hasVectors()) {
|
||||||
for (int i = 0; i < VECTOR_EXTENSIONS.length; i++) {
|
for (int i = 0; i < IndexFileNames.VECTOR_EXTENSIONS.length; i++) {
|
||||||
files.add(segment + "." + VECTOR_EXTENSIONS[i]);
|
files.add(segment + "." + IndexFileNames.VECTOR_EXTENSIONS[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,8 +248,8 @@ class SegmentReader extends IndexReader {
|
||||||
Vector files() throws IOException {
|
Vector files() throws IOException {
|
||||||
Vector files = new Vector(16);
|
Vector files = new Vector(16);
|
||||||
|
|
||||||
for (int i = 0; i < FILENAME_EXTENSIONS.length; i++) {
|
for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.length; i++) {
|
||||||
String name = segment + "." + FILENAME_EXTENSIONS[i];
|
String name = segment + "." + IndexFileNames.INDEX_EXTENSIONS[i];
|
||||||
if (directory().fileExists(name))
|
if (directory().fileExists(name))
|
||||||
files.addElement(name);
|
files.addElement(name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue