jainankitk commented on code in PR #14397:
URL: https://github.com/apache/lucene/pull/14397#discussion_r2021747427
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java:
##########
@@ -512,6 +512,7 @@ private void doReset(int docID) throws IOException {
bytes.offset = bytes.length = 0;
for (int decompressed = 0; decompressed < totalLength; ) {
final int toDecompress = Math.min(totalLength - decompressed,
chunkSize);
+ decompressor.reset();
decompressor.decompress(fieldsStream, toDecompress, 0,
toDecompress, spare);
Review Comment:
> When the block changes, we must discard the cache in time, this operation
can only be detected from external.
I am not questioning that. My point is to not have `reset` method in the
Decompressor interface, and add another decompress method that takes
`reuseIfPossible` as one of the parameters. It ensures the functional
correctness even if we don't make the `reset` call from somewhere in the code.
And, allows explicit optimization wherever we deem appropriate. The risk in not
explicitly making the `reset` call is much more than using original decompress
without the reuse.
```
public abstract class Decompressor implements Cloneable {
protected Decompressor() {}
public void decompress(
DataInput in, int originalLength, int offset, int length, BytesRef
bytes) throws IOException {
decompress(in, originalLength, offset, length, bytes, false);
}
public abstract void decompress(
DataInput in, int originalLength, int offset, int length, BytesRef
bytes, boolean reuseIfPossible) throws IOException;
@Override
public abstract Decompressor clone();
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]