lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r168449 - in /lucene/java/trunk/src/java/org/apache/lucene: index/IndexReader.java index/SegmentReader.java store/FSDirectory.java
Date Thu, 05 May 2005 22:20:51 GMT
Author: dnaber
Date: Thu May  5 15:20:49 2005
New Revision: 168449

URL: http://svn.apache.org/viewcvs?rev=168449&view=rev
Log:
refactoring so that filename extensions are in one place

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=168449&r1=168448&r2=168449&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Thu May  5 15:20:49
2005
@@ -50,6 +50,16 @@
 */
 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() { }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=168449&r1=168448&r2=168449&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Thu May  5 15:20:49
2005
@@ -247,12 +247,9 @@
 
   Vector files() throws IOException {
     Vector files = new Vector(16);
-    final String ext[] = new String[]{
-      "cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del",
-      "tvx", "tvd", "tvf", "tvp" };
 
-    for (int i = 0; i < ext.length; i++) {
-      String name = segment + "." + ext[i];
+    for (int i = 0; i < FILENAME_EXTENSIONS.length; i++) {
+      String name = segment + "." + FILENAME_EXTENSIONS[i];
       if (directory().fileExists(name))
         files.addElement(name);
     }

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java?rev=168449&r1=168448&r2=168449&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java Thu May  5 15:20:49
2005
@@ -26,6 +26,7 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.Constants;
 
 /**
@@ -47,19 +48,11 @@
      * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
      */
     public boolean accept(File dir, String name) {
-      if (name.endsWith(".cfs")) return true;
-      else if (name.endsWith(".fnm")) return true;
-      else if (name.endsWith(".fdt")) return true;
-      else if (name.endsWith(".fdx")) return true;
-      else if (name.endsWith(".frq")) return true;
-      else if (name.endsWith(".prx")) return true;
-      else if (name.endsWith(".tii")) return true;
-      else if (name.endsWith(".tis")) return true;
-      else if (name.endsWith(".tvd")) return true;
-      else if (name.endsWith(".tvf")) return true;
-      else if (name.endsWith(".tvx")) return true;
-      else if (name.endsWith(".del")) return true;
-      else if (name.equals("deletable")) return true;
+      for (int i = 0; i < IndexReader.FILENAME_EXTENSIONS.length; i++) {
+        if (name.endsWith("."+IndexReader.FILENAME_EXTENSIONS[i]))
+          return true;
+      }
+      if (name.equals("deletable")) return true;
       else if (name.equals("segments")) return true;
       else if (name.matches(".+\\.f\\d+")) return true;
       return false;



Mime
View raw message