Index: lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java
===================================================================
--- lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java	(revision 1396060)
+++ lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java	(working copy)
@@ -130,8 +130,8 @@
  *   <li>Term Metadata --&gt; DocFPDelta, PosFPDelta?, PosVIntBlockFPDelta?, PayFPDelta?, 
  *                            SkipFPDelta?</li>
  *   <li>Header, --&gt; {@link CodecUtil#writeHeader CodecHeader}</li>
- *   <li>PackedBlockSize, PosVIntBlockFPDelta, SkipFPDelta --&gt; {@link DataOutput#writeVInt VInt}</li>
- *   <li>DocFPDelta, PosFPDelta, PayFPDelta --&gt; {@link DataOutput#writeVLong VLong}</li>
+ *   <li>PackedBlockSize --&gt; {@link DataOutput#writeVInt VInt}</li>
+ *   <li>DocFPDelta, PosFPDelta, PayFPDelta, PosVIntBlockFPDelta, SkipFPDelta --&gt; {@link DataOutput#writeVLong VLong}</li>
  * </ul>
  * <p>Notes:</p>
  * <ul>
Index: lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java
===================================================================
--- lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java	(revision 1396049)
+++ lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java	(working copy)
@@ -350,10 +350,10 @@
     public final long docStartFP;
     public final long posStartFP;
     public final long payStartFP;
-    public final int skipOffset;
-    public final int lastPosBlockOffset;
+    public final long skipOffset;
+    public final long lastPosBlockOffset;
 
-    public PendingTerm(long docStartFP, long posStartFP, long payStartFP, int skipOffset, int lastPosBlockOffset) {
+    public PendingTerm(long docStartFP, long posStartFP, long payStartFP, long skipOffset, long lastPosBlockOffset) {
       this.docStartFP = docStartFP;
       this.posStartFP = posStartFP;
       this.payStartFP = payStartFP;
@@ -397,7 +397,7 @@
       }
     }
 
-    final int lastPosBlockOffset;
+    final long lastPosBlockOffset;
 
     if (fieldHasPositions) {
       // if (DEBUG) {
@@ -411,7 +411,7 @@
       assert stats.totalTermFreq != -1;
       if (stats.totalTermFreq > BLOCK_SIZE) {
         // record file offset for last pos in last block
-        lastPosBlockOffset = (int) (posOut.getFilePointer() - posTermStartFP);
+        lastPosBlockOffset = posOut.getFilePointer() - posTermStartFP;
       } else {
         lastPosBlockOffset = -1;
       }
@@ -474,9 +474,9 @@
       lastPosBlockOffset = -1;
     }
 
-    int skipOffset;
+    long skipOffset;
     if (docCount > BLOCK_SIZE) {
-      skipOffset = (int) (skipWriter.writeSkip(docOut) - docTermStartFP);
+      skipOffset = skipWriter.writeSkip(docOut) - docTermStartFP;
       
       // if (DEBUG) {
       //   System.out.println("skip packet " + (docOut.getFilePointer() - (docTermStartFP + skipOffset)) + " bytes");
@@ -534,7 +534,7 @@
         bytesWriter.writeVLong(term.posStartFP - lastPosStartFP);
         lastPosStartFP = term.posStartFP;
         if (term.lastPosBlockOffset != -1) {
-          bytesWriter.writeVInt(term.lastPosBlockOffset);
+          bytesWriter.writeVLong(term.lastPosBlockOffset);
         }
         if ((fieldHasPayloads || fieldHasOffsets) && term.payStartFP != -1) {
           bytesWriter.writeVLong(term.payStartFP - lastPayStartFP);
@@ -543,7 +543,7 @@
       }
 
       if (term.skipOffset != -1) {
-        bytesWriter.writeVInt(term.skipOffset);
+        bytesWriter.writeVLong(term.skipOffset);
       }
     }
 
Index: lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsReader.java
===================================================================
--- lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsReader.java	(revision 1396049)
+++ lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsReader.java	(working copy)
@@ -145,8 +145,8 @@
     long docStartFP;
     long posStartFP;
     long payStartFP;
-    int skipOffset;
-    int lastPosBlockOffset;
+    long skipOffset;
+    long lastPosBlockOffset;
 
     // Only used by the "primary" TermState -- clones don't
     // copy this (basically they are "transient"):
@@ -226,7 +226,7 @@
       if (fieldHasPositions) {
         termState.posStartFP = in.readVLong();
         if (termState.totalTermFreq > BLOCK_SIZE) {
-          termState.lastPosBlockOffset = in.readVInt();
+          termState.lastPosBlockOffset = in.readVLong();
         } else {
           termState.lastPosBlockOffset = -1;
         }
@@ -241,7 +241,7 @@
       if (fieldHasPositions) {
         termState.posStartFP += in.readVLong();
         if (termState.totalTermFreq > BLOCK_SIZE) {
-          termState.lastPosBlockOffset = in.readVInt();
+          termState.lastPosBlockOffset = in.readVLong();
         } else {
           termState.lastPosBlockOffset = -1;
         }
@@ -257,7 +257,7 @@
     }
 
     if (termState.docFreq > BLOCK_SIZE) {
-      termState.skipOffset = in.readVInt();
+      termState.skipOffset = in.readVLong();
     } else {
       termState.skipOffset = -1;
     }
@@ -344,7 +344,7 @@
     // Where this term's skip data starts (after
     // docTermStartFP) in the .doc file (or -1 if there is
     // no skip data for this term):
-    private int skipOffset;
+    private long skipOffset;
 
     // docID for next skip point, we won't use skipper if 
     // target docID is not larger than this
@@ -621,7 +621,7 @@
     // Where this term's skip data starts (after
     // docTermStartFP) in the .doc file (or -1 if there is
     // no skip data for this term):
-    private int skipOffset;
+    private long skipOffset;
 
     private int nextSkipDoc;
 
@@ -1035,7 +1035,7 @@
     // Where this term's skip data starts (after
     // docTermStartFP) in the .doc file (or -1 if there is
     // no skip data for this term):
-    private int skipOffset;
+    private long skipOffset;
 
     private int nextSkipDoc;
 
Index: lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java	(revision 0)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java	(working copy)
@@ -0,0 +1,151 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.FieldInfo.IndexOptions;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TimeUnits;
+import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.junit.Ignore;
+
+import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
+
+/**
+ * Test indexes 2B docs with 65k freqs each, 
+ * so you get > Integer.MAX_VALUE postings data for the term
+ * @lucene.experimental
+ */
+@SuppressCodecs({ "SimpleText", "Memory", "Direct" })
+@TimeoutSuite(millis = 4 * TimeUnits.HOUR)
+public class Test2BPostingsBytes extends LuceneTestCase {
+
+  // @Absurd @Ignore takes ~20GB-30GB of space and 10 minutes.
+  // with some codecs needs more heap space as well.
+  @Ignore("Very slow. Enable manually by removing @Ignore.")
+  public void test() throws Exception {
+    BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes1"));
+    if (dir instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
+    }
+    
+    IndexWriter w = new IndexWriter(dir,
+        new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
+        .setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
+        .setRAMBufferSizeMB(256.0)
+        .setMergeScheduler(new ConcurrentMergeScheduler())
+        .setMergePolicy(newLogMergePolicy(false, 10))
+        .setOpenMode(IndexWriterConfig.OpenMode.CREATE));
+
+    MergePolicy mp = w.getConfig().getMergePolicy();
+    if (mp instanceof LogByteSizeMergePolicy) {
+     // 1 petabyte:
+     ((LogByteSizeMergePolicy) mp).setMaxMergeMB(1024*1024*1024);
+    }
+
+    Document doc = new Document();
+    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+    ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
+    ft.setOmitNorms(true);
+    MyTokenStream tokenStream = new MyTokenStream();
+    Field field = new Field("field", tokenStream, ft);
+    doc.add(field);
+    
+    final int numDocs = 1000;
+    for (int i = 0; i < numDocs; i++) {
+      if (i % 2 == 1) { // trick blockPF's little optimization
+        tokenStream.n = 65536;
+      } else {
+        tokenStream.n = 65537;
+      }
+      w.addDocument(doc);
+    }
+    w.forceMerge(1);
+    w.close();
+    
+    DirectoryReader oneThousand = DirectoryReader.open(dir);
+    IndexReader subReaders[] = new IndexReader[1000];
+    Arrays.fill(subReaders, oneThousand);
+    MultiReader mr = new MultiReader(subReaders);
+    BaseDirectoryWrapper dir2 = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes2"));
+    if (dir2 instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper)dir2).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
+    }
+    IndexWriter w2 = new IndexWriter(dir2,
+        new IndexWriterConfig(TEST_VERSION_CURRENT, null));
+    w2.addIndexes(mr);
+    w2.forceMerge(1);
+    w2.close();
+    oneThousand.close();
+    
+    DirectoryReader oneMillion = DirectoryReader.open(dir2);
+    subReaders = new IndexReader[2000];
+    Arrays.fill(subReaders, oneMillion);
+    mr = new MultiReader(subReaders);
+    BaseDirectoryWrapper dir3 = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes3"));
+    if (dir3 instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper)dir3).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
+    }
+    IndexWriter w3 = new IndexWriter(dir3,
+        new IndexWriterConfig(TEST_VERSION_CURRENT, null));
+    w3.addIndexes(mr);
+    w3.forceMerge(1);
+    w3.close();
+    oneMillion.close();
+    
+    dir.close();
+    dir2.close();
+    dir3.close();
+  }
+  
+  public static final class MyTokenStream extends TokenStream {
+    private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
+    int index;
+    int n;
+
+    public MyTokenStream() {
+      termAtt.setLength(1);
+      termAtt.buffer()[0] = 'a';
+    }
+    
+    @Override
+    public boolean incrementToken() {
+      if (index < n) {
+        index++;
+        return true;
+      }
+      return false;
+    }
+    
+    @Override
+    public void reset() {
+      index = 0;
+    }
+  }
+}

Property changes on: lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
Index: lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java	(revision 0)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java	(working copy)
@@ -0,0 +1,111 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TimeUnits;
+import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.junit.Ignore;
+
+import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
+
+/**
+ * Test indexes ~82M docs with 52 positions each, so you get > Integer.MAX_VALUE positions
+ * @lucene.experimental
+ */
+@SuppressCodecs({ "SimpleText", "Memory", "Direct" })
+@TimeoutSuite(millis = 4 * TimeUnits.HOUR)
+public class Test2BPositions extends LuceneTestCase {
+
+  // uses lots of space and takes a few minutes
+  @Ignore("Very slow. Enable manually by removing @Ignore.")
+  public void test() throws Exception {
+    BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BPositions"));
+    if (dir instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
+    }
+    
+    IndexWriter w = new IndexWriter(dir,
+        new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
+        .setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
+        .setRAMBufferSizeMB(256.0)
+        .setMergeScheduler(new ConcurrentMergeScheduler())
+        .setMergePolicy(newLogMergePolicy(false, 10))
+        .setOpenMode(IndexWriterConfig.OpenMode.CREATE));
+
+    MergePolicy mp = w.getConfig().getMergePolicy();
+    if (mp instanceof LogByteSizeMergePolicy) {
+     // 1 petabyte:
+     ((LogByteSizeMergePolicy) mp).setMaxMergeMB(1024*1024*1024);
+    }
+
+    Document doc = new Document();
+    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+    ft.setOmitNorms(true);
+    Field field = new Field("field", new MyTokenStream(), ft);
+    doc.add(field);
+    
+    final int numDocs = (Integer.MAX_VALUE / 26) + 1;
+    for (int i = 0; i < numDocs; i++) {
+      w.addDocument(doc);
+      if (VERBOSE && i % 100000 == 0) {
+        System.out.println(i + " of " + numDocs + "...");
+      }
+    }
+    w.forceMerge(1);
+    w.close();
+    dir.close();
+  }
+  
+  public static final class MyTokenStream extends TokenStream {
+    private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
+    private final PositionIncrementAttribute posIncAtt = addAttribute(PositionIncrementAttribute.class);
+    int index;
+
+    public MyTokenStream() {
+      termAtt.setLength(1);
+      termAtt.buffer()[0] = 'a';
+    }
+    
+    @Override
+    public boolean incrementToken() {
+      if (index < 52) {
+        posIncAtt.setPositionIncrement(1+index);
+        index++;
+        return true;
+      }
+      return false;
+    }
+    
+    @Override
+    public void reset() {
+      index = 0;
+    }
+  }
+}

Property changes on: lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java	(revision 1396049)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java	(working copy)
@@ -53,7 +53,8 @@
   
   // Increment version to change it:
   final static int VERSION_START = 0;
-  final static int VERSION_CURRENT = VERSION_START;
+  final static int VERSION_LONG_SKIP = 1;
+  final static int VERSION_CURRENT = VERSION_LONG_SKIP;
 
   final IndexOutput freqOut;
   final IndexOutput proxOut;
@@ -277,9 +278,9 @@
   private static class PendingTerm {
     public final long freqStart;
     public final long proxStart;
-    public final int skipOffset;
+    public final long skipOffset;
 
-    public PendingTerm(long freqStart, long proxStart, int skipOffset) {
+    public PendingTerm(long freqStart, long proxStart, long skipOffset) {
       this.freqStart = freqStart;
       this.proxStart = proxStart;
       this.skipOffset = skipOffset;
@@ -299,9 +300,9 @@
     // for this term) in two places?
     assert stats.docFreq == df;
 
-    final int skipOffset;
+    final long skipOffset;
     if (df >= skipMinimum) {
-      skipOffset = (int) (skipListWriter.writeSkip(freqOut)-freqStart);
+      skipOffset = skipListWriter.writeSkip(freqOut)-freqStart;
     } else {
       skipOffset = -1;
     }
@@ -333,7 +334,7 @@
 
     if (firstTerm.skipOffset != -1) {
       assert firstTerm.skipOffset > 0;
-      bytesWriter.writeVInt(firstTerm.skipOffset);
+      bytesWriter.writeVLong(firstTerm.skipOffset);
     }
     if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
       bytesWriter.writeVLong(firstTerm.proxStart);
@@ -348,7 +349,7 @@
       lastFreqStart = term.freqStart;
       if (term.skipOffset != -1) {
         assert term.skipOffset > 0;
-        bytesWriter.writeVInt(term.skipOffset);
+        bytesWriter.writeVLong(term.skipOffset);
       }
       if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
         bytesWriter.writeVLong(term.proxStart - lastProxStart);
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java	(revision 1396060)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java	(working copy)
@@ -65,8 +65,7 @@
  *    <li>Term Metadata --&gt; FreqDelta, SkipDelta?, ProxDelta?
  *    <li>Header --&gt; {@link CodecUtil#writeHeader CodecHeader}</li>
  *    <li>SkipInterval,MaxSkipLevels,SkipMinimum --&gt; {@link DataOutput#writeInt Uint32}</li>
- *    <li>SkipDelta --&gt; {@link DataOutput#writeVInt VInt}</li>
- *    <li>FreqDelta,ProxDelta --&gt; {@link DataOutput#writeVLong VLong}</li>
+ *    <li>SkipDelta, FreqDelta,ProxDelta --&gt; {@link DataOutput#writeVLong VLong}</li>
  * </ul>
  * <p>Notes:</p>
  * <ul>
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java	(revision 1396049)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java	(working copy)
@@ -67,7 +67,7 @@
     try {
       freqIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, segmentSuffix, Lucene40PostingsFormat.FREQ_EXTENSION),
                            ioContext);
-      CodecUtil.checkHeader(freqIn, Lucene40PostingsWriter.FRQ_CODEC, Lucene40PostingsWriter.VERSION_START,Lucene40PostingsWriter.VERSION_START);
+      CodecUtil.checkHeader(freqIn, Lucene40PostingsWriter.FRQ_CODEC, Lucene40PostingsWriter.VERSION_START,Lucene40PostingsWriter.VERSION_CURRENT);
       // TODO: hasProx should (somehow!) become codec private,
       // but it's tricky because 1) FIS.hasProx is global (it
       // could be all fields that have prox are written by a
@@ -79,7 +79,7 @@
       if (fieldInfos.hasProx()) {
         proxIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, segmentSuffix, Lucene40PostingsFormat.PROX_EXTENSION),
                              ioContext);
-        CodecUtil.checkHeader(proxIn, Lucene40PostingsWriter.PRX_CODEC, Lucene40PostingsWriter.VERSION_START,Lucene40PostingsWriter.VERSION_START);
+        CodecUtil.checkHeader(proxIn, Lucene40PostingsWriter.PRX_CODEC, Lucene40PostingsWriter.VERSION_START,Lucene40PostingsWriter.VERSION_CURRENT);
       } else {
         proxIn = null;
       }
@@ -98,7 +98,7 @@
 
     // Make sure we are talking to the matching past writer
     CodecUtil.checkHeader(termsIn, Lucene40PostingsWriter.TERMS_CODEC,
-      Lucene40PostingsWriter.VERSION_START, Lucene40PostingsWriter.VERSION_START);
+      Lucene40PostingsWriter.VERSION_START, Lucene40PostingsWriter.VERSION_CURRENT);
 
     skipInterval = termsIn.readInt();
     maxSkipLevels = termsIn.readInt();
@@ -109,7 +109,7 @@
   private final static class StandardTermState extends BlockTermState {
     long freqOffset;
     long proxOffset;
-    int skipOffset;
+    long skipOffset;
 
     // Only used by the "primary" TermState -- clones don't
     // copy this (basically they are "transient"):
@@ -202,7 +202,7 @@
     assert termState.freqOffset < freqIn.length();
 
     if (termState.docFreq >= skipMinimum) {
-      termState.skipOffset = termState.bytesReader.readVInt();
+      termState.skipOffset = termState.bytesReader.readVLong();
       // if (DEBUG) System.out.println("  skipOffset=" + termState.skipOffset + " vs freqIn.length=" + freqIn.length());
       assert termState.freqOffset + termState.skipOffset < freqIn.length();
     } else {
@@ -319,7 +319,7 @@
 
 
     protected long freqOffset;
-    protected int skipOffset;
+    protected long skipOffset;
 
     protected boolean skipped;
     protected final Bits liveDocs;
@@ -695,7 +695,7 @@
     Bits liveDocs;
 
     long freqOffset;
-    int skipOffset;
+    long skipOffset;
     long proxOffset;
 
     int posPendingCount;
@@ -894,7 +894,7 @@
     Bits liveDocs;
 
     long freqOffset;
-    int skipOffset;
+    long skipOffset;
     long proxOffset;
 
     int posPendingCount;
