(index-reverse) Entry Sources reset() their LongQueryBuffer

Previously this was the responsibility of the caller, which lead to the possibility of passing in improperly prepared buffers and receiving bad outcome
This commit is contained in:
Viktor Lofgren 2024-07-09 01:39:40 +02:00
parent 12a2ab93db
commit 0d29e2a39d
3 changed files with 2 additions and 2 deletions

View File

@ -36,6 +36,7 @@ public class FullIndexEntrySource implements EntrySource {
@Override
public void read(LongQueryBuffer buffer) {
buffer.reset();
buffer.end = min(buffer.end, endOffset - pos);
reader.readData(buffer.data, buffer.end, pos);
pos += buffer.end;

View File

@ -42,6 +42,7 @@ public class PrioIndexEntrySource implements EntrySource {
@SneakyThrows
@SuppressWarnings("preview")
public void read(LongQueryBuffer buffer) {
buffer.reset();
buffer.end = min(buffer.end, endOffsetL - posL);
var byteBuffer = buffer.data.getMemorySegment().asByteBuffer();

View File

@ -73,8 +73,6 @@ public class IndexQuery {
private boolean fillBuffer(LongQueryBuffer dest) {
for (;;) {
dest.reset();
EntrySource source = sources.get(si);
source.read(dest);