mirror of https://github.com/apache/lucene.git
Skip decoding tail freqs when they are not needed. (#12832)
When we moved to group-varint for tail postings, we stop interleaving docs and freqs and instead wrote all docs first, then all freqs. This means that we can now skip decoding frequencies when they are not needed.
This commit is contained in:
parent
4628327af0
commit
5bc608dbad
|
@ -142,10 +142,15 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
|
||||
/** Read values that have been written using variable-length encoding instead of bit-packing. */
|
||||
static void readVIntBlock(
|
||||
IndexInput docIn, long[] docBuffer, long[] freqBuffer, int num, boolean indexHasFreq)
|
||||
IndexInput docIn,
|
||||
long[] docBuffer,
|
||||
long[] freqBuffer,
|
||||
int num,
|
||||
boolean indexHasFreq,
|
||||
boolean decodeFreq)
|
||||
throws IOException {
|
||||
GroupVIntReader.readValues(docIn, docBuffer, num);
|
||||
if (indexHasFreq) {
|
||||
if (indexHasFreq && decodeFreq) {
|
||||
for (int i = 0; i < num; ++i) {
|
||||
freqBuffer[i] = docBuffer[i] & 0x01;
|
||||
docBuffer[i] >>= 1;
|
||||
|
@ -153,6 +158,10 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
freqBuffer[i] = docIn.readVInt();
|
||||
}
|
||||
}
|
||||
} else if (indexHasFreq) {
|
||||
for (int i = 0; i < num; ++i) {
|
||||
docBuffer[i] >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +475,7 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
blockUpto++;
|
||||
} else {
|
||||
// Read vInts:
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreq);
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreq, needsFreq);
|
||||
prefixSum(docBuffer, left, accum);
|
||||
docBuffer[left] = NO_MORE_DOCS;
|
||||
blockUpto += left;
|
||||
|
@ -759,7 +768,7 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
docBuffer[1] = NO_MORE_DOCS;
|
||||
blockUpto++;
|
||||
} else {
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, true);
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, true, true);
|
||||
prefixSum(docBuffer, left, accum);
|
||||
docBuffer[left] = NO_MORE_DOCS;
|
||||
blockUpto += left;
|
||||
|
@ -1146,7 +1155,7 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
}
|
||||
blockUpto += BLOCK_SIZE;
|
||||
} else {
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreqs);
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreqs, true);
|
||||
prefixSum(docBuffer, left, accum);
|
||||
docBuffer[left] = NO_MORE_DOCS;
|
||||
blockUpto += left;
|
||||
|
@ -1354,7 +1363,7 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
forDeltaUtil.decodeAndPrefixSum(docIn, accum, docBuffer);
|
||||
pforUtil.decode(docIn, freqBuffer);
|
||||
} else {
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, true);
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, true, true);
|
||||
prefixSum(docBuffer, left, accum);
|
||||
docBuffer[left] = NO_MORE_DOCS;
|
||||
}
|
||||
|
@ -1744,7 +1753,7 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
|
|||
false; // freq block will be loaded lazily when necessary, we don't load it here
|
||||
}
|
||||
} else {
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreq);
|
||||
readVIntBlock(docIn, docBuffer, freqBuffer, left, indexHasFreq, true);
|
||||
prefixSum(docBuffer, left, accum);
|
||||
docBuffer[left] = NO_MORE_DOCS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue