Skip to content

Commit 63cf167

Browse files
committed
tweak
1 parent b1c8e24 commit 63cf167

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,9 +1423,21 @@ public void loadDoc(BlockLoader.IntBuilder builder, int docId) throws IOExceptio
14231423
@Override
14241424
public void loadBlock(BlockLoader.SingletonOrdinalsBuilder builder, BlockLoader.Docs docs, int offset) throws IOException {
14251425
for (int i = offset; i < docs.count(); i++) {
1426-
doc = docs.get(i);
1427-
builder.appendOrd(Math.toIntExact(longValue()));
1426+
final int index = docs.get(i);
1427+
final int blockIndex = index >>> ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SHIFT;
1428+
final int blockInIndex = index & ES819TSDBDocValuesFormat.NUMERIC_BLOCK_MASK;
1429+
if (blockIndex != currentBlockIndex) {
1430+
assert blockIndex > currentBlockIndex : blockIndex + " < " + currentBlockIndex;
1431+
// no need to seek if the loading block is the next block
1432+
if (currentBlockIndex + 1 != blockIndex) {
1433+
valuesData.seek(indexReader.get(blockIndex));
1434+
}
1435+
currentBlockIndex = blockIndex;
1436+
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
1437+
}
1438+
builder.appendOrd(Math.toIntExact(currentBlock[blockInIndex]));
14281439
}
1440+
doc = docs.get(docs.count() - 1);
14291441
}
14301442

14311443
@Override

0 commit comments

Comments
 (0)