Skip to content

Commit 6dfb5dc

Browse files
authored
Streamline and optimize check to use decode or decode ordinals. (#133047)
Comparing bitsPerOrd == -1 should be a little bit more optimal compared to maxOrd >= 0 (int vs long comparison).
1 parent a5c0852 commit 6dfb5dc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,10 @@ public long longValue() throws IOException {
12761276
valuesData.seek(indexReader.get(blockIndex));
12771277
}
12781278
currentBlockIndex = blockIndex;
1279-
if (maxOrd >= 0) {
1280-
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
1281-
} else {
1279+
if (bitsPerOrd == -1) {
12821280
decoder.decode(valuesData, currentBlock);
1281+
} else {
1282+
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
12831283
}
12841284
return currentBlock[blockInIndex];
12851285
}
@@ -1347,7 +1347,7 @@ long lookAheadValueAt(int targetDoc) throws IOException {
13471347
if (lookaheadBlockIndex + 1 != blockIndex) {
13481348
lookaheadData.seek(indexReader.get(blockIndex));
13491349
}
1350-
if (maxOrd == -1L) {
1350+
if (bitsPerOrd == -1) {
13511351
decoder.decode(lookaheadData, lookaheadBlock);
13521352
} else {
13531353
decoder.decodeOrdinals(lookaheadData, lookaheadBlock, bitsPerOrd);
@@ -1417,10 +1417,10 @@ public long longValue() throws IOException {
14171417
valuesData.seek(indexReader.get(blockIndex));
14181418
}
14191419
currentBlockIndex = blockIndex;
1420-
if (maxOrd >= 0) {
1421-
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
1422-
} else {
1420+
if (bitsPerOrd == -1) {
14231421
decoder.decode(valuesData, currentBlock);
1422+
} else {
1423+
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
14241424
}
14251425
}
14261426
return currentBlock[blockInIndex];
@@ -1452,10 +1452,10 @@ long advance(long index) throws IOException {
14521452
valuesData.seek(indexReader.get(blockIndex));
14531453
}
14541454
currentBlockIndex = blockIndex;
1455-
if (bitsPerOrd >= 0) {
1456-
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
1457-
} else {
1455+
if (bitsPerOrd == -1) {
14581456
decoder.decode(valuesData, currentBlock);
1457+
} else {
1458+
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
14591459
}
14601460
}
14611461
return currentBlock[blockInIndex];

0 commit comments

Comments
 (0)