lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r518529 - /lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
Date Thu, 15 Mar 2007 09:08:08 GMT
Author: doronc
Date: Thu Mar 15 02:08:07 2007
New Revision: 518529

URL: http://svn.apache.org/viewvc?view=rev&rev=518529
Log:
maintain most recent file format in a single line in the code.
(this is less bug prone.)

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java?view=diff&rev=518529&r1=518528&r2=518529
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java Thu Mar 15 02:08:07
2007
@@ -29,6 +29,7 @@
 
 final class SegmentInfos extends Vector {
   
+  
   /** The file format version, a negative number. */
   /* Works since counter, the old 1st entry, is always >= 0 */
   public static final int FORMAT = -1;
@@ -44,13 +45,15 @@
    */
   public static final int FORMAT_LOCKLESS = -2;
 
-  /** This is the current file format written.  It adds a
-   * "hasSingleNormFile" flag into each segment info.
+  /** This format adds a "hasSingleNormFile" flag into each segment info.
    * See <a href="http://issues.apache.org/jira/browse/LUCENE-756">LUCENE-756</a>
    * for details.
    */
   public static final int FORMAT_SINGLE_NORM_FILE = -3;
 
+  /* This must always point to the most recent file format. */
+  private static final int CURRENT_FORMAT = FORMAT_SINGLE_NORM_FILE;
+  
   public int counter = 0;    // used to name new segments
   /**
    * counts how often the index has been changed by adding or deleting docs.
@@ -84,7 +87,6 @@
       return -1;
     }
     long max = -1;
-    int prefixLen = IndexFileNames.SEGMENTS.length()+1;
     for (int i = 0; i < files.length; i++) {
       String file = files[i];
       if (file.startsWith(IndexFileNames.SEGMENTS) && !file.equals(IndexFileNames.SEGMENTS_GEN))
{
@@ -198,7 +200,7 @@
       int format = input.readInt();
       if(format < 0){     // file contains explicit format info
         // check that it is a format we can understand
-        if (format < FORMAT_SINGLE_NORM_FILE)
+        if (format < CURRENT_FORMAT)
           throw new CorruptIndexException("Unknown format version: " + format);
         version = input.readLong(); // read version
         counter = input.readInt(); // read counter
@@ -263,7 +265,7 @@
     boolean success = false;
 
     try {
-      output.writeInt(FORMAT_SINGLE_NORM_FILE); // write FORMAT
+      output.writeInt(CURRENT_FORMAT); // write FORMAT
       output.writeLong(++version); // every write changes
                                    // the index
       output.writeInt(counter); // write counter
@@ -343,7 +345,7 @@
           try {
             format = input.readInt();
             if(format < 0){
-              if (format < FORMAT_SINGLE_NORM_FILE)
+              if (format < CURRENT_FORMAT)
                 throw new CorruptIndexException("Unknown format version: " + format);
               version = input.readLong(); // read version
             }



Mime
View raw message