jpountz commented on a change in pull request #779: LUCENE-8762: Introduce
Specialized Impacts For Doc + Freq
URL: https://github.com/apache/lucene-solr/pull/779#discussion_r303852373
##########
File path:
lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java
##########
@@ -1761,6 +1763,198 @@ public long cost() {
}
+ final class BlockImpactsDocsEnum extends ImpactsEnum {
+
+ private final byte[] encoded;
+
+ private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
+ private final int[] freqBuffer = new int[MAX_DATA_SIZE];
+
+ private int docBufferUpto;
+
+ private final Lucene50ScoreSkipReader skipper;
+
+ final IndexInput docIn;
+
+ final boolean indexHasPos;
+ final boolean indexHasOffsets;
+ final boolean indexHasPayloads;
+ final boolean indexHasFreq;
+
+ private int docFreq; // number of docs 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
+ private int freq; // freq we last read
+
+ // Where this term's postings start in the .doc file:
+ private long docTermStartFP;
+
+ // 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;
+
+ private int nextSkipDoc = -1;
+
+ private long seekTo = -1;
+
+ public BlockImpactsDocsEnum(FieldInfo fieldInfo, IntBlockTermState
termState) throws IOException {
+ indexHasOffsets =
fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS)
>= 0;
+ indexHasPayloads = fieldInfo.hasPayloads();
+ indexHasPos =
fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
>= 0;
+ indexHasFreq =
fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
+
+ this.docIn = Lucene50PostingsReader.this.docIn.clone();
+
+ encoded = new byte[MAX_ENCODED_SIZE];
+
+ docFreq = termState.docFreq;
+ docTermStartFP = termState.docStartFP;
+ posTermStartFP = termState.posStartFP;
+ payTermStartFP = termState.payStartFP;
+ docIn.seek(docTermStartFP);
+
+ doc = -1;
+ accum = 0;
+ docUpto = 0;
+ docBufferUpto = BLOCK_SIZE;
+
+ if (indexHasFreq == false) {
+ Arrays.fill(freqBuffer, 1);
+ }
+
+ skipper = new Lucene50ScoreSkipReader(version,
+ docIn.clone(),
+ MAX_SKIP_LEVELS,
+ indexHasPos,
+ indexHasOffsets,
+ indexHasPayloads);
+ skipper.init(docTermStartFP+termState.skipOffset, docTermStartFP,
posTermStartFP, payTermStartFP, docFreq);
+ }
+
+ @Override
+ public int freq() {
+ return freq;
+ }
+
+ @Override
+ public int docID() {
+ return doc;
+ }
+
+ private void refillDocs() throws IOException {
+ final int left = docFreq - docUpto;
+ assert left > 0;
+
+ if (left >= BLOCK_SIZE) {
+ forUtil.readBlock(docIn, encoded, docDeltaBuffer);
+ if (indexHasFreq) {
Review comment:
can you read freqs lazily like BlockDocsEnum?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]