You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/06/11 17:26:32 UTC

svn commit: r1348902 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java

Author: rmuir
Date: Mon Jun 11 15:26:31 2012
New Revision: 1348902

URL: http://svn.apache.org/viewvc?rev=1348902&view=rev
Log:
LUCENE-4086: remove 3.x CFS support from trunk

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java?rev=1348902&r1=1348901&r2=1348902&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java Mon Jun 11 15:26:31 2012
@@ -19,8 +19,8 @@ package org.apache.lucene.store;
 
 import org.apache.lucene.codecs.Codec; // javadocs
 import org.apache.lucene.codecs.LiveDocsFormat; // javadocs
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.IndexFormatTooOldException;
 import org.apache.lucene.store.DataOutput; // javadocs
 import org.apache.lucene.util.IOUtils;
 
@@ -141,16 +141,15 @@ public final class CompoundFileDirectory
             fileEntry.offset = input.readLong();
             fileEntry.length = input.readLong();
           }
+          success = true;
           return mapping;
         } finally {
           IOUtils.close(input);
         }
       } else {
-        // TODO remove once 3.x is not supported anymore
-        mapping = readLegacyEntries(stream, firstInt);
+        throw new IndexFormatTooOldException(stream, firstInt, 
+            CompoundFileWriter.FORMAT_CURRENT, CompoundFileWriter.FORMAT_CURRENT);
       }
-      success = true;
-      return mapping;
     } finally {
       if (success) {
         IOUtils.close(stream);
@@ -159,61 +158,6 @@ public final class CompoundFileDirectory
       }
     }
   }
-
-  private static Map<String, FileEntry> readLegacyEntries(IndexInput stream,
-      int firstInt) throws CorruptIndexException, IOException {
-    final Map<String,FileEntry> entries = new HashMap<String,FileEntry>();
-    final int count;
-    final boolean stripSegmentName;
-    if (firstInt < CompoundFileWriter.FORMAT_PRE_VERSION) {
-      if (firstInt < CompoundFileWriter.FORMAT_CURRENT) {
-        throw new CorruptIndexException("Incompatible format version: "
-            + firstInt + " expected " + CompoundFileWriter.FORMAT_CURRENT + " (resource: " + stream + ")");
-      }
-      // It's a post-3.1 index, read the count.
-      count = stream.readVInt();
-      stripSegmentName = false;
-    } else {
-      count = firstInt;
-      stripSegmentName = true;
-    }
-    
-    // read the directory and init files
-    long streamLength = stream.length();
-    FileEntry entry = null;
-    for (int i=0; i<count; i++) {
-      long offset = stream.readLong();
-      if (offset < 0 || offset > streamLength) {
-        throw new CorruptIndexException("Invalid CFS entry offset: " + offset + " (resource: " + stream + ")");
-      }
-      String id = stream.readString();
-      
-      if (stripSegmentName) {
-        // Fix the id to not include the segment names. This is relevant for
-        // pre-3.1 indexes.
-        id = IndexFileNames.stripSegmentName(id);
-      }
-      
-      if (entry != null) {
-        // set length of the previous entry
-        entry.length = offset - entry.offset;
-      }
-      
-      entry = new FileEntry();
-      entry.offset = offset;
-
-      assert !entries.containsKey(id);
-
-      entries.put(id, entry);
-    }
-    
-    // set the length of the final entry
-    if (entry != null) {
-      entry.length = streamLength - entry.offset;
-    }
-    
-    return entries;
-  }
   
   public Directory getDirectory() {
     return directory;