diff --git a/lucene/core/src/generated/checksums/generateForDeltaUtil.json b/lucene/core/src/generated/checksums/generateForDeltaUtil.json index 6546e25c4be..26ebc1198d9 100644 --- a/lucene/core/src/generated/checksums/generateForDeltaUtil.json +++ b/lucene/core/src/generated/checksums/generateForDeltaUtil.json @@ -1,4 +1,4 @@ { - "lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java": "5115b12ac31537ce31d73c0a279df92060749a3a", - "lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py": "db6154406e68b80d2c90116b5d0bfa9ba220762a" + "lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java": "f561578ccb6a95364bb62c5ed86b38ff0b4a009d", + "lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py": "eea1a71be9da8a13fdd979354dc4a8c6edf21be1" } \ No newline at end of file diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java index 25601388a0f..f13b3cde69c 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/ForDeltaUtil.java @@ -23,7 +23,6 @@ import static org.apache.lucene.codecs.lucene912.ForUtil.*; import java.io.IOException; import org.apache.lucene.internal.vectorization.PostingDecodingUtil; import org.apache.lucene.store.DataOutput; -import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.packed.PackedInts; /** @@ -282,11 +281,6 @@ public final class ForDeltaUtil { } } - void skip(IndexInput in) throws IOException { - final int bitsPerValue = Byte.toUnsignedInt(in.readByte()); - in.skipBytes(numBytes(bitsPerValue)); - } - /** Delta-decode 128 integers into {@code longs}. */ void decodeAndPrefixSum(int bitsPerValue, PostingDecodingUtil pdu, long base, long[] longs) throws IOException { diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java index 9c65078cfa9..b2b95e7c877 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java @@ -77,8 +77,6 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private final int maxNumImpactsAtLevel1; private final int maxImpactNumBytesAtLevel1; - private final int version; - /** Sole constructor. */ public Lucene912PostingsReader(SegmentReadState state) throws IOException { String metaName = @@ -87,6 +85,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final long expectedDocFileLength, expectedPosFileLength, expectedPayFileLength; ChecksumIndexInput metaIn = null; boolean success = false; + int version; try { metaIn = state.directory.openChecksumInput(metaName); version = @@ -236,13 +235,6 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute) throws IOException { final IntBlockTermState termState = (IntBlockTermState) _termState; - final boolean fieldHasPositions = - fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; - final boolean fieldHasOffsets = - fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) - >= 0; - final boolean fieldHasPayloads = fieldInfo.hasPayloads(); - if (absolute) { termState.docStartFP = 0; termState.posStartFP = 0; @@ -263,9 +255,13 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { termState.singletonDocID += BitUtil.zigZagDecode(l >>> 1); } - if (fieldHasPositions) { + if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) { termState.posStartFP += in.readVLong(); - if (fieldHasOffsets || fieldHasPayloads) { + if (fieldInfo + .getIndexOptions() + .compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) + >= 0 + || fieldInfo.hasPayloads()) { termState.payStartFP += in.readVLong(); } if (termState.totalTermFreq > BLOCK_SIZE) { @@ -344,17 +340,14 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final class BlockDocsEnum extends PostingsEnum { - final ForUtil forUtil = new ForUtil(); final ForDeltaUtil forDeltaUtil = new ForDeltaUtil(); - final PForUtil pforUtil = new PForUtil(forUtil); + final PForUtil pforUtil = new PForUtil(new ForUtil()); private final long[] docBuffer = new long[BLOCK_SIZE + 1]; private final long[] freqBuffer = new long[BLOCK_SIZE]; private int docBufferUpto; - final IndexInput startDocIn; - IndexInput docIn; PostingDecodingUtil docInUtil; final boolean indexHasFreq; @@ -378,8 +371,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1 private long freqFP; - public BlockDocsEnum(FieldInfo fieldInfo) throws IOException { - this.startDocIn = Lucene912PostingsReader.this.docIn; + public BlockDocsEnum(FieldInfo fieldInfo) { this.docIn = null; indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0; indexHasPos = @@ -396,7 +388,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) { - return docIn == startDocIn + return docIn == Lucene912PostingsReader.this.docIn && indexHasFreq == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0) && indexHasPos @@ -417,7 +409,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { if (docFreq > 1) { if (docIn == null) { // lazy init - docIn = startDocIn.clone(); + docIn = Lucene912PostingsReader.this.docIn.clone(); docInUtil = VECTORIZATION_PROVIDER.newPostingDecodingUtil(docIn); } prefetchPostings(docIn, termState); @@ -460,22 +452,22 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public int nextPosition() throws IOException { + public int nextPosition() { return -1; } @Override - public int startOffset() throws IOException { + public int startOffset() { return -1; } @Override - public int endOffset() throws IOException { + public int endOffset() { return -1; } @Override - public BytesRef getPayload() throws IOException { + public BytesRef getPayload() { return null; } @@ -493,7 +485,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { if (needsFreq) { freqFP = docIn.getFilePointer(); } - pforUtil.skip(docIn); + PForUtil.skip(docIn); } docCountUpto += BLOCK_SIZE; prevDocID = docBuffer[BLOCK_SIZE - 1]; @@ -629,9 +621,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final class EverythingEnum extends PostingsEnum { - final ForUtil forUtil = new ForUtil(); final ForDeltaUtil forDeltaUtil = new ForDeltaUtil(); - final PForUtil pforUtil = new PForUtil(forUtil); + final PForUtil pforUtil = new PForUtil(new ForUtil()); private final long[] docBuffer = new long[BLOCK_SIZE + 1]; private final long[] freqBuffer = new long[BLOCK_SIZE + 1]; @@ -652,8 +643,6 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private int docBufferUpto; private int posBufferUpto; - final IndexInput startDocIn; - IndexInput docIn; PostingDecodingUtil docInUtil; final IndexInput posIn; @@ -663,7 +652,6 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final BytesRef payload; final boolean indexHasFreq; - final boolean indexHasPos; final boolean indexHasOffsets; final boolean indexHasPayloads; final boolean indexHasOffsetsOrPayloads; @@ -680,13 +668,6 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { // skip these to "catch up": private long posPendingCount; - // Where this term's postings start in the .pos file: - private long posTermStartFP; - - // Where this term's payloads/offsets start in the .pay - // file: - private long payTermStartFP; - // File pointer where the last (vInt encoded) pos delta // block is. We need this to know whether to bulk // decode vs vInt decode the block: @@ -713,11 +694,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1 public EverythingEnum(FieldInfo fieldInfo) throws IOException { - this.startDocIn = Lucene912PostingsReader.this.docIn; this.docIn = null; indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0; - indexHasPos = - fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; indexHasOffsets = fieldInfo .getIndexOptions() @@ -761,7 +739,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) { - return docIn == startDocIn + return docIn == Lucene912PostingsReader.this.docIn && indexHasOffsets == (fieldInfo .getIndexOptions() @@ -772,14 +750,17 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { public PostingsEnum reset(IntBlockTermState termState, int flags) throws IOException { docFreq = termState.docFreq; - posTermStartFP = termState.posStartFP; - payTermStartFP = termState.payStartFP; + // Where this term's postings start in the .pos file: + final long posTermStartFP = termState.posStartFP; + // Where this term's payloads/offsets start in the .pay + // file: + final long payTermStartFP = termState.payStartFP; totalTermFreq = termState.totalTermFreq; singletonDocID = termState.singletonDocID; if (docFreq > 1) { if (docIn == null) { // lazy init - docIn = startDocIn.clone(); + docIn = Lucene912PostingsReader.this.docIn.clone(); docInUtil = VECTORIZATION_PROVIDER.newPostingDecodingUtil(docIn); } prefetchPostings(docIn, termState); @@ -829,7 +810,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public int freq() throws IOException { + public int freq() { return freq; } @@ -1054,11 +1035,11 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { toSkip -= leftInBlock; while (toSkip >= BLOCK_SIZE) { assert posIn.getFilePointer() != lastPosBlockFP; - pforUtil.skip(posIn); + PForUtil.skip(posIn); if (indexHasPayloads) { // Skip payloadLength block: - pforUtil.skip(payIn); + PForUtil.skip(payIn); // Skip payloadBytes block: int numBytes = payIn.readVInt(); @@ -1066,14 +1047,13 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } if (indexHasOffsets) { - pforUtil.skip(payIn); - pforUtil.skip(payIn); + PForUtil.skip(payIn); + PForUtil.skip(payIn); } toSkip -= BLOCK_SIZE; } refillPositions(); payloadByteUpto = 0; - posBufferUpto = 0; final int toSkipInt = (int) toSkip; if (indexHasPayloads) { for (int i = 0; i < toSkipInt; ++i) { @@ -1137,7 +1117,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } else { // this works, because when writing a vint block we always force the first length to be // written - pforUtil.skip(payIn); // skip over lengths + PForUtil.skip(payIn); // skip over lengths int numBytes = payIn.readVInt(); // read length of payloadBytes payIn.seek(payIn.getFilePointer() + numBytes); // skip over payloadBytes } @@ -1151,8 +1131,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } else { // this works, because when writing a vint block we always force the first length to be // written - pforUtil.skip(payIn); // skip over starts - pforUtil.skip(payIn); // skip over lengths + PForUtil.skip(payIn); // skip over starts + PForUtil.skip(payIn); // skip over lengths } } } @@ -1219,24 +1199,20 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final class BlockImpactsDocsEnum extends ImpactsEnum { - final ForUtil forUtil = new ForUtil(); final ForDeltaUtil forDeltaUtil = new ForDeltaUtil(); - final PForUtil pforUtil = new PForUtil(forUtil); + final PForUtil pforUtil = new PForUtil(new ForUtil()); private final long[] docBuffer = new long[BLOCK_SIZE + 1]; private final long[] freqBuffer = new long[BLOCK_SIZE]; private int docBufferUpto; - final IndexInput startDocIn; - final IndexInput docIn; final PostingDecodingUtil docInUtil; final boolean indexHasFreq; final boolean indexHasPos; - final boolean indexHasOffsetsOrPayloads; - private int docFreq; // number of docs in this posting list + private final int docFreq; // number of docs in this posting list private int docCountUpto; // number of docs in or before the current block private int doc; // doc we last read private long prevDocID; // last doc ID of the previous block @@ -1245,39 +1221,32 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { // true if we shallow-advanced to a new block that we have not decoded yet private boolean needsRefilling; + private final ByteArrayDataInput scratch = new ByteArrayDataInput(); + // level 0 skip data private int level0LastDocID; private long level0DocEndFP; private final BytesRef level0SerializedImpacts; - private final ByteArrayDataInput level0SerializedImpactsIn = new ByteArrayDataInput(); private final MutableImpactList level0Impacts; // level 1 skip data private int level1LastDocID; private long level1DocEndFP; private int level1DocCountUpto; private final BytesRef level1SerializedImpacts; - private final ByteArrayDataInput level1SerializedImpactsIn = new ByteArrayDataInput(); private final MutableImpactList level1Impacts; public BlockImpactsDocsEnum(FieldInfo fieldInfo, IntBlockTermState termState) throws IOException { - this.startDocIn = Lucene912PostingsReader.this.docIn; indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0; indexHasPos = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; - indexHasOffsetsOrPayloads = - fieldInfo - .getIndexOptions() - .compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) - >= 0 - || fieldInfo.hasPayloads(); // We set the last element of docBuffer to NO_MORE_DOCS, it helps save conditionals in // advance() docBuffer[BLOCK_SIZE] = NO_MORE_DOCS; docFreq = termState.docFreq; if (docFreq > 1) { - docIn = startDocIn.clone(); + docIn = Lucene912PostingsReader.this.docIn.clone(); docInUtil = VECTORIZATION_PROVIDER.newPostingDecodingUtil(docIn); prefetchPostings(docIn, termState); } else { @@ -1323,22 +1292,22 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public int nextPosition() throws IOException { + public int nextPosition() { return -1; } @Override - public int startOffset() throws IOException { + public int startOffset() { return -1; } @Override - public int endOffset() throws IOException { + public int endOffset() { return -1; } @Override - public BytesRef getPayload() throws IOException { + public BytesRef getPayload() { return null; } @@ -1356,7 +1325,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { if (indexHasFreq) { freqFP = docIn.getFilePointer(); - pforUtil.skip(docIn); + PForUtil.skip(docIn); } docCountUpto += BLOCK_SIZE; } else { @@ -1502,7 +1471,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public Impacts getImpacts() throws IOException { + public Impacts getImpacts() { return new Impacts() { @Override @@ -1529,13 +1498,9 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { level--; } - if (level1LastDocID != NO_MORE_DOCS) { - if (level == 0) { - return level1LastDocID; - } - level--; + if (level == 0) { + return level1LastDocID; } - return NO_MORE_DOCS; } @@ -1543,22 +1508,17 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { public List getImpacts(int level) { if (level0LastDocID != NO_MORE_DOCS) { if (level == 0) { - level0SerializedImpactsIn.reset( - level0SerializedImpacts.bytes, 0, level0SerializedImpacts.length); - readImpacts(level0SerializedImpactsIn, level0Impacts); + scratch.reset(level0SerializedImpacts.bytes, 0, level0SerializedImpacts.length); + readImpacts(scratch, level0Impacts); return level0Impacts; } level--; } - if (level1LastDocID != NO_MORE_DOCS) { - if (level == 0) { - level1SerializedImpactsIn.reset( - level1SerializedImpacts.bytes, 0, level1SerializedImpacts.length); - readImpacts(level1SerializedImpactsIn, level1Impacts); - return level1Impacts; - } - level--; + if (level1LastDocID != NO_MORE_DOCS && level == 0) { + scratch.reset(level1SerializedImpacts.bytes, 0, level1SerializedImpacts.length); + readImpacts(scratch, level1Impacts); + return level1Impacts; } return Collections.singletonList(new Impact(Integer.MAX_VALUE, 1L)); @@ -1574,9 +1534,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { final class BlockImpactsPostingsEnum extends ImpactsEnum { - final ForUtil forUtil = new ForUtil(); final ForDeltaUtil forDeltaUtil = new ForDeltaUtil(); - final PForUtil pforUtil = new PForUtil(forUtil); + final PForUtil pforUtil = new PForUtil(new ForUtil()); private final long[] docBuffer = new long[BLOCK_SIZE + 1]; private final long[] freqBuffer = new long[BLOCK_SIZE]; @@ -1585,21 +1544,19 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private int docBufferUpto; private int posBufferUpto; - final IndexInput startDocIn; - final IndexInput docIn; final PostingDecodingUtil docInUtil; final IndexInput posIn; final PostingDecodingUtil posInUtil; final boolean indexHasFreq; - final boolean indexHasPos; final boolean indexHasOffsets; final boolean indexHasPayloads; final boolean indexHasOffsetsOrPayloads; - private int docFreq; // number of docs in this posting list - private long totalTermFreq; // sum of freqBuffer in this posting list (or docFreq when omitted) + private final int docFreq; // number of docs in this posting list + private final long + totalTermFreq; // sum of freqBuffer in this posting list (or docFreq when omitted) private int docCountUpto; // number of docs in or before the current block private int doc; // doc we last read private long prevDocID; // last doc ID of the previous block @@ -1610,24 +1567,22 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { // skip these to "catch up": private long posPendingCount; - // Where this term's postings start in the .pos file: - private long posTermStartFP; - // File pointer where the last (vInt encoded) pos delta // block is. We need this to know whether to bulk // decode vs vInt decode the block: - private long lastPosBlockFP; + private final long lastPosBlockFP; // true if we shallow-advanced to a new block that we have not decoded yet private boolean needsRefilling; + private final ByteArrayDataInput scratch = new ByteArrayDataInput(); + // level 0 skip data private int level0LastDocID; private long level0DocEndFP; private long level0PosEndFP; private int level0BlockPosUpto; private final BytesRefBuilder level0SerializedImpacts = new BytesRefBuilder(); - private final ByteArrayDataInput level0SerializedImpactsIn = new ByteArrayDataInput(); private final MutableImpactList level0Impacts; // level 1 skip data private int level1LastDocID; @@ -1636,17 +1591,13 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { private long level1PosEndFP; private int level1BlockPosUpto; private final BytesRefBuilder level1SerializedImpacts = new BytesRefBuilder(); - private final ByteArrayDataInput level1SerializedImpactsIn = new ByteArrayDataInput(); private final MutableImpactList level1Impacts; - private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1 + private final int singletonDocID; // docid when there is a single pulsed posting, otherwise -1 public BlockImpactsPostingsEnum(FieldInfo fieldInfo, IntBlockTermState termState) throws IOException { - this.startDocIn = Lucene912PostingsReader.this.docIn; indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0; - indexHasPos = - fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; indexHasOffsets = fieldInfo .getIndexOptions() @@ -1663,11 +1614,12 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { docBuffer[BLOCK_SIZE] = NO_MORE_DOCS; docFreq = termState.docFreq; - posTermStartFP = termState.posStartFP; + // Where this term's postings start in the .pos file: + final long posTermStartFP = termState.posStartFP; totalTermFreq = termState.totalTermFreq; singletonDocID = termState.singletonDocID; if (docFreq > 1) { - docIn = startDocIn.clone(); + docIn = Lucene912PostingsReader.this.docIn.clone(); docInUtil = VECTORIZATION_PROVIDER.newPostingDecodingUtil(docIn); prefetchPostings(docIn, termState); } else { @@ -1710,7 +1662,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public int freq() throws IOException { + public int freq() { return freq; } @@ -1850,7 +1802,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } @Override - public Impacts getImpacts() throws IOException { + public Impacts getImpacts() { return new Impacts() { @Override @@ -1877,11 +1829,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { level--; } - if (level1LastDocID != NO_MORE_DOCS) { - if (level == 0) { - return level1LastDocID; - } - level--; + if (level1LastDocID != NO_MORE_DOCS && level == 0) { + return level1LastDocID; } return NO_MORE_DOCS; @@ -1891,22 +1840,17 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { public List getImpacts(int level) { if (level0LastDocID != NO_MORE_DOCS) { if (level == 0) { - level0SerializedImpactsIn.reset( - level0SerializedImpacts.bytes(), 0, level0SerializedImpacts.length()); - readImpacts(level0SerializedImpactsIn, level0Impacts); + scratch.reset(level0SerializedImpacts.bytes(), 0, level0SerializedImpacts.length()); + readImpacts(scratch, level0Impacts); return level0Impacts; } level--; } - if (level1LastDocID != NO_MORE_DOCS) { - if (level == 0) { - level1SerializedImpactsIn.reset( - level1SerializedImpacts.bytes(), 0, level1SerializedImpacts.length()); - readImpacts(level1SerializedImpactsIn, level1Impacts); - return level1Impacts; - } - level--; + if (level1LastDocID != NO_MORE_DOCS && level == 0) { + scratch.reset(level1SerializedImpacts.bytes(), 0, level1SerializedImpacts.length()); + readImpacts(scratch, level1Impacts); + return level1Impacts; } return Collections.singletonList(new Impact(Integer.MAX_VALUE, 1L)); @@ -1962,7 +1906,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { toSkip -= leftInBlock; while (toSkip >= BLOCK_SIZE) { assert posIn.getFilePointer() != lastPosBlockFP; - pforUtil.skip(posIn); + PForUtil.skip(posIn); toSkip -= BLOCK_SIZE; } refillPositions(); @@ -2067,7 +2011,8 @@ public final class Lucene912PostingsReader extends PostingsReaderBase { } } - private void prefetchPostings(IndexInput docIn, IntBlockTermState state) throws IOException { + private static void prefetchPostings(IndexInput docIn, IntBlockTermState state) + throws IOException { assert state.docFreq > 1; // Singletons are inlined in the terms dict, nothing to prefetch if (docIn.getFilePointer() != state.docStartFP) { // Don't prefetch if the input is already positioned at the right offset, which suggests that diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsWriter.java index 3d493622c05..df34510de07 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsWriter.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsWriter.java @@ -342,7 +342,7 @@ public class Lucene912PostingsWriter extends PushPostingsWriterBase { } @Override - public void finishDoc() throws IOException { + public void finishDoc() { docBufferUpto++; docCount++; @@ -443,7 +443,6 @@ public class Lucene912PostingsWriter extends PushPostingsWriterBase { private void writeLevel1SkipData() throws IOException { docOut.writeVInt(docID - level1LastDocID); - long numImpactBytes = scratchOutput.size(); final long level1End; if (writeFreqs) { List impacts = level1CompetitiveFreqNormAccumulator.getCompetitiveFreqNormPairs(); @@ -451,7 +450,7 @@ public class Lucene912PostingsWriter extends PushPostingsWriterBase { maxNumImpactsAtLevel1 = impacts.size(); } writeImpacts(impacts, scratchOutput); - numImpactBytes = scratchOutput.size(); + long numImpactBytes = scratchOutput.size(); if (numImpactBytes > maxImpactNumBytesAtLevel1) { maxImpactNumBytesAtLevel1 = Math.toIntExact(numImpactBytes); } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/PForUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/PForUtil.java index 798101b6531..3857eabbe44 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/PForUtil.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/PForUtil.java @@ -121,7 +121,7 @@ final class PForUtil { } /** Skip 128 integers. */ - void skip(DataInput in) throws IOException { + static void skip(DataInput in) throws IOException { final int token = Byte.toUnsignedInt(in.readByte()); final int bitsPerValue = token & 0x1f; final int numExceptions = token >>> 5; diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py index b3bf493c86b..56c402372a6 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/gen_ForDeltaUtil.py @@ -308,11 +308,6 @@ public final class ForDeltaUtil { } } - void skip(IndexInput in) throws IOException { - final int bitsPerValue = Byte.toUnsignedInt(in.readByte()); - in.skipBytes(numBytes(bitsPerValue)); - } - """ def primitive_size_for_bpv(bpv): diff --git a/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldDocValuesFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldDocValuesFormat.java index c47bcae79f8..2e45e232b5f 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldDocValuesFormat.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldDocValuesFormat.java @@ -254,7 +254,7 @@ public abstract class PerFieldDocValuesFormat extends DocValuesFormat { } } - private class FieldsReader extends DocValuesProducer { + private static class FieldsReader extends DocValuesProducer { private final Map fields = new HashMap<>(); private final Map formats = new HashMap<>(); diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene912/TestPForUtil.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene912/TestPForUtil.java index 0740a8a708b..ccc786293a1 100644 --- a/lucene/core/src/test/org/apache/lucene/codecs/lucene912/TestPForUtil.java +++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene912/TestPForUtil.java @@ -46,7 +46,7 @@ public class TestPForUtil extends LuceneTestCase { final PForUtil pforUtil = new PForUtil(forUtil); for (int i = 0; i < iterations; ++i) { if (random().nextInt(5) == 0) { - pforUtil.skip(in); + PForUtil.skip(in); continue; } final long[] restored = new long[ForUtil.BLOCK_SIZE];