easyice commented on code in PR #12842: URL: https://github.com/apache/lucene/pull/12842#discussion_r1501300476
########## lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java: ########## @@ -428,12 +443,36 @@ void reset(Sorter.DocMap docMap, PostingsEnum in, boolean storePositions, boolea this.postingInput = buffer.toDataInput(); } - private void addPositions(final PostingsEnum in, final DataOutput out) throws IOException { - int freq = in.freq(); - out.writeVInt(freq); - if (storePositions) { - int previousPosition = 0; - int previousEndOffset = 0; + private void writePositionsWithOffsets(final PostingsEnum in, final DataOutput out, int freq) + throws IOException { + int previousPosition = 0; + int previousEndOffset = 0; + for (int i = 0; i < freq; i++) { + final int pos = in.nextPosition(); + final BytesRef payload = in.getPayload(); + // The low-order bit of token is set only if there is a payload, the + // previous bits are the delta-encoded position. + final int token = (pos - previousPosition) << 1 | (payload == null ? 0 : 1); + previousPosition = pos; + + final int startOffset = in.startOffset(); + final int endOffset = in.endOffset(); + posDeltaBuffer[0] = token; + posDeltaBuffer[1] = startOffset - previousEndOffset; + posDeltaBuffer[2] = endOffset - startOffset; + posDeltaBuffer[3] = payload == null ? 0 : payload.length; + groupVIntWriter.writeValues(out, posDeltaBuffer, 4); + previousEndOffset = endOffset; + if (payload != null) { + out.writeBytes(payload.bytes, payload.offset, payload.length); + } + } + } + + private void writePositionsWithOutOffsets(final PostingsEnum in, final DataOutput out, int freq) + throws IOException { + int previousPosition = 0; + if (storePayloads) { Review Comment: Thanks for looking this! I will update this later next week. -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org