diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index b94a00d9a5a..4bce4455a78 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -105,6 +105,9 @@ Optimizations the postings data (via flags to TermsEnum.docs/docsAndPositions) to use ForUtil.skipBlock. (Robert Muir) +* LUCENE-4497: Don't write PosVIntCount to the positions file in + Lucene41PostingsFormat, as its always totalTermFreq % BLOCK_SIZE. (Robert Muir) + Build * LUCENE-4451: Memory leak per unique thread caused by diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java index 3cbc9653bed..df87cb61080 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java @@ -274,7 +274,7 @@ import org.apache.lucene.util.packed.PackedInts; *
  • Header --> {@link CodecUtil#writeHeader CodecHeader}
  • *
  • TermPositions --> <PackedPosDeltaBlock> PackedPosBlockNum, * VIntBlock?
  • - *
  • VIntBlock --> PosVIntCount, <PositionDelta[, PayloadLength?], PayloadData?, + *
  • VIntBlock --> <PositionDelta[, PayloadLength?], PayloadData?, * OffsetDelta?, OffsetLength?>PosVIntCount *
  • PackedPosDeltaBlock --> {@link PackedInts PackedInts}
  • *
  • PosVIntCount, PositionDelta, OffsetDelta, OffsetLength --> diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java index 8c52f2723e4..5979ad75116 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java @@ -597,6 +597,7 @@ public final class Lucene41PostingsReader extends PostingsReaderBase { final boolean indexHasPayloads; private int docFreq; // number of docs in this posting list + private long totalTermFreq; // number of positions in this posting list private int docUpto; // how many docs we've read private int doc; // doc we last read private int accum; // accumulator for doc deltas @@ -661,6 +662,7 @@ public final class Lucene41PostingsReader extends PostingsReaderBase { payTermStartFP = termState.payStartFP; docIn.seek(docTermStartFP); skipOffset = termState.skipOffset; + totalTermFreq = termState.totalTermFreq; posPendingFP = posTermStartFP; posPendingCount = 0; if (termState.totalTermFreq < BLOCK_SIZE) { @@ -721,7 +723,7 @@ public final class Lucene41PostingsReader extends PostingsReaderBase { // if (DEBUG) { // System.out.println(" vInt pos block @ fp=" + posIn.getFilePointer() + " hasPayloads=" + indexHasPayloads + " hasOffsets=" + indexHasOffsets); // } - final int count = posIn.readVInt(); + final int count = (int) (totalTermFreq % BLOCK_SIZE); int payloadLength = 0; for(int i=0;i