Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static final class Impl extends SourceOperator {
private LongVector.Builder timestampsBuilder;
private TsidBuilder tsHashesBuilder;
private SegmentsIterator iterator;
private final List<ValuesSourceReaderOperator.FieldInfo> fieldsToExact;
private final List<ValuesSourceReaderOperator.FieldInfo> fieldsToExtracts;
private ShardLevelFieldsReader fieldsReader;
private DocIdCollector docCollector;

Expand All @@ -142,7 +142,7 @@ static final class Impl extends SourceOperator {
) {
this.maxPageSize = maxPageSize;
this.blockFactory = blockFactory;
this.fieldsToExact = fieldsToExtract;
this.fieldsToExtracts = fieldsToExtract;
this.emitDocIds = emitDocIds;
this.remainingDocs = limit;
this.timestampsBuilder = blockFactory.newLongVectorBuilder(Math.min(limit, maxPageSize));
Expand Down Expand Up @@ -172,7 +172,7 @@ public Page getOutput() {
}

Page page = null;
Block[] blocks = new Block[(emitDocIds ? 3 : 2) + fieldsToExact.size()];
Block[] blocks = new Block[(emitDocIds ? 3 : 2) + fieldsToExtracts.size()];
try {
if (iterator == null) {
var slice = sliceQueue.nextSlice();
Expand All @@ -181,7 +181,7 @@ public Page getOutput() {
return null;
}
Releasables.close(fieldsReader);
fieldsReader = new ShardLevelFieldsReader(blockFactory, slice.shardContext(), fieldsToExact);
fieldsReader = new ShardLevelFieldsReader(blockFactory, slice.shardContext(), fieldsToExtracts);
iterator = new SegmentsIterator(slice);
if (emitDocIds) {
docCollector = new DocIdCollector(blockFactory, slice.shardContext());
Expand All @@ -194,14 +194,14 @@ public Page getOutput() {
iterator.readDocsForNextPage();
if (currentPagePos > 0) {
int blockIndex = 0;
if (emitDocIds) {
if (docCollector != null) {
blocks[blockIndex++] = docCollector.build().asBlock();
}
blocks[blockIndex++] = tsHashesBuilder.build().asBlock();
tsHashesBuilder = new TsidBuilder(blockFactory, Math.min(remainingDocs, maxPageSize));
blocks[blockIndex++] = timestampsBuilder.build().asBlock();
timestampsBuilder = blockFactory.newLongVectorBuilder(Math.min(remainingDocs, maxPageSize));
System.arraycopy(fieldsReader.buildBlocks(), 0, blocks, blockIndex, fieldsToExact.size());
System.arraycopy(fieldsReader.buildBlocks(), 0, blocks, blockIndex, fieldsToExtracts.size());
page = new Page(currentPagePos, blocks);
currentPagePos = 0;
}
Expand Down Expand Up @@ -436,10 +436,12 @@ static final class ShardLevelFieldsReader implements Releasable {
}
if (storedFieldsSpec.requiresSource()) {
sourceLoader = shardContext.newSourceLoader();
storedFieldsSpec = storedFieldsSpec.merge(new StoredFieldsSpec(false, false, sourceLoader.requiredStoredFields()));
} else {
sourceLoader = null;
}
this.storedFieldsSpec = storedFieldsSpec;
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, removed 144f13d

}

void readValues(int segment, int docID) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testSimple() {
int numSamplesPerTS = 10;
long timestampStart = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parseMillis("2024-01-01T00:00:00Z");
int maxPageSize = between(1, 1024);
List<Page> results = runDriver(1024, maxPageSize, true, numTimeSeries, numSamplesPerTS, timestampStart);
List<Page> results = runDriver(1024, maxPageSize, randomBoolean(), numTimeSeries, numSamplesPerTS, timestampStart);
// for now we emit at most one time series each page
int offset = 0;
for (Page page : results) {
Expand Down