Skip to content

Commit

Permalink
Delta code prox offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpountz committed Jan 26, 2024
1 parent 2a3bfef commit 0afc5c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void write(Fields fields, NormsProducer norms) throws IOException {
int maxTermLength = 0;
int numPending = 0;
BytesRefBuilder prevTerm = new BytesRefBuilder();
long prevProxOffset = 0;
for (BytesRef term = te.next(); term != null; term = te.next()) {
pe = te.postings(pe, flags);
if (pe.nextDoc() == DocIdSetIterator.NO_MORE_DOCS) {
Expand All @@ -153,7 +154,8 @@ public void write(Fields fields, NormsProducer norms) throws IOException {
termsOut.writeVLong(writer.totalTermFreq);
}
if (hasPositions) {
termsOut.writeLong(proxOffset);
termsOut.writeVLong(proxOffset - prevProxOffset);
prevProxOffset = proxOffset;
}
termsOut.writeVLong(postingsOut.size() - postingsStartPointer);
++numPending;
Expand All @@ -165,6 +167,7 @@ public void write(Fields fields, NormsProducer norms) throws IOException {
numPending = 0;
++numBlocks;
prevTerm.setLength(0);
prevProxOffset = 0;
} else {
prevTerm.copyBytes(term);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ private void loadFrame() throws IOException {
long termsFP = index.getFilePointer();
state.blockPostingsFP = termsFP + termBytes;
state.docOffset = state.blockPostingsFP;
state.proxOffset = 0;
state.termPostingsBytes = 0L;
decompressTerms((int) termBytes, (int) originalTermsBytes);
loadedFrameIndex = state.blockIndex;
Expand All @@ -481,6 +482,7 @@ private void resetFrame() throws IOException {
state.termIndexInBlock = 0;
termsReader.setPosition(0);
state.docOffset = state.blockPostingsFP;
state.proxOffset = 0;
state.termPostingsBytes = 0L;
index.seek(state.blockPostingsFP);
}
Expand All @@ -499,7 +501,7 @@ private void scanNextTermInCurrentFrame() throws IOException {
state.totalTermFreq = state.docFreq;
}
if (meta.options.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
state.proxOffset = termsReader.readLong();
state.proxOffset += termsReader.readVLong();
}
state.docOffset += state.termPostingsBytes;
state.termPostingsBytes = termsReader.readVLong();
Expand Down

0 comments on commit 0afc5c6

Please sign in to comment.