Index: src/java/org/apache/lucene/index/SegmentTermEnum.java =================================================================== --- src/java/org/apache/lucene/index/SegmentTermEnum.java (revision 389043) +++ src/java/org/apache/lucene/index/SegmentTermEnum.java (working copy) @@ -62,7 +62,15 @@ if (format < TermInfosWriter.FORMAT) throw new IOException("Unknown format version:" + format); - size = input.readLong(); // read the size + if (format >= -2){ + size = input.readLong(); // read the size + } else { + // real size is at the end of the file. + long filePos = input.getFilePointer(); + input.seek(input.length() - 8); + size = input.readLong(); + input.seek(filePos); + } if(format == -1){ if (!isIndex) { Index: src/java/org/apache/lucene/index/TermInfosWriter.java =================================================================== --- src/java/org/apache/lucene/index/TermInfosWriter.java (revision 389043) +++ src/java/org/apache/lucene/index/TermInfosWriter.java (working copy) @@ -27,7 +27,7 @@ final class TermInfosWriter { /** The file format version, a negative number. */ - public static final int FORMAT = -2; + public static final int FORMAT = -3; private FieldInfos fieldInfos; private IndexOutput output; @@ -81,7 +81,6 @@ isIndex = isi; output = directory.createOutput(segment + (isIndex ? ".tii" : ".tis")); output.writeInt(FORMAT); // write format - output.writeLong(0); // leave space for size output.writeInt(indexInterval); // write indexInterval output.writeInt(skipInterval); // write skipInterval } @@ -137,7 +136,6 @@ /** Called to complete TermInfos creation. */ final void close() throws IOException { - output.seek(4); // write size after format output.writeLong(size); output.close();