Skip to content

Commit f74f9ec

Browse files
committed
Fallback to tryRead(...) if look ahead finds multiple ordinals
1 parent a84961e commit f74f9ec

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesProducer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public BlockLoader.Block tryRead(BlockLoader.BlockFactory factory, BlockLoader.D
398398
}
399399
// TODO: Since ordinals are sorted, start at 0 (offset by startValue), scan until lastValue,
400400
// then fill remaining positions with lastValue.
401-
return null;
401+
// Falling back to tryRead(...) is safe here, given that current block index wasn't altered by looking ahead.
402402
}
403403
try (var builder = factory.singletonOrdinalsBuilder(this, docs.count() - offset, true)) {
404404
BlockLoader.SingletonLongBuilder delegate = new SingletonLongToSingletonOrdinalDelegate(builder);

server/src/test/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormatTests.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,20 +1139,11 @@ public int get(int docId) {
11391139
return docId;
11401140
}
11411141
}, start);
1142-
Set<String> seenValues = new HashSet<>();
1143-
for (int p = start; p <= end; p++) {
1144-
String hostName = hostnames.get(((Number) idBlock.get(p)).intValue());
1145-
seenValues.add(hostName);
1146-
}
1147-
if (seenValues.size() == 1) {
1148-
assertNotNull(hostBlock);
1149-
assertThat(hostBlock.size(), equalTo(end - start + 1));
1150-
for (int i = 0; i < hostBlock.size(); i++) {
1151-
String actualHostName = BytesRefs.toString(hostBlock.get(i));
1152-
assertThat(actualHostName, equalTo(hostnames.get(((Number) idBlock.get(i + start)).intValue())));
1153-
}
1154-
} else {
1155-
assertNull(hostBlock);
1142+
assertNotNull(hostBlock);
1143+
assertThat(hostBlock.size(), equalTo(end - start + 1));
1144+
for (int i = 0; i < hostBlock.size(); i++) {
1145+
String actualHostName = BytesRefs.toString(hostBlock.get(i));
1146+
assertThat(actualHostName, equalTo(hostnames.get(((Number) idBlock.get(i + start)).intValue())));
11561147
}
11571148
if (start == idBlock.size() - 1) {
11581149
break;

0 commit comments

Comments
 (0)