Skip to content
Merged
Changes from all 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 @@ -1232,8 +1232,9 @@ private static void readTermDict(IndexInput meta, TermsDictEntry entry) throws I
entry.termsIndexAddressesLength = meta.readLong();
}

private abstract static class NumericValues {
abstract long advance(long index) throws IOException;
@FunctionalInterface
private interface NumericValues {
long advance(long index) throws IOException;
}

static final class SortedOrdinalReader {
Expand Down Expand Up @@ -1603,30 +1604,26 @@ private NumericValues getValues(NumericEntry entry, final long maxOrd) throws IO

final IndexInput valuesData = data.slice("values", entry.valuesOffset, entry.valuesLength);
final int bitsPerOrd = maxOrd >= 0 ? PackedInts.bitsRequired(maxOrd - 1) : -1;
return new NumericValues() {

private final TSDBDocValuesEncoder decoder = new TSDBDocValuesEncoder(ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE);
private long currentBlockIndex = -1;
private final long[] currentBlock = new long[ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE];

@Override
long advance(long index) throws IOException {
final long blockIndex = index >>> ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SHIFT;
final int blockInIndex = (int) (index & ES819TSDBDocValuesFormat.NUMERIC_BLOCK_MASK);
if (blockIndex != currentBlockIndex) {
// no need to seek if the loading block is the next block
if (currentBlockIndex + 1 != blockIndex) {
valuesData.seek(indexReader.get(blockIndex));
}
currentBlockIndex = blockIndex;
if (bitsPerOrd == -1) {
decoder.decode(valuesData, currentBlock);
} else {
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
}
final long[] currentBlockIndex = { -1 };
final long[] currentBlock = new long[ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE];
final TSDBDocValuesEncoder decoder = new TSDBDocValuesEncoder(ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE);
return index -> {
final long blockIndex = index >>> ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SHIFT;
final int blockInIndex = (int) (index & ES819TSDBDocValuesFormat.NUMERIC_BLOCK_MASK);
if (blockIndex != currentBlockIndex[0]) {
// no need to seek if the loading block is the next block
if (currentBlockIndex[0] + 1 != blockIndex) {
valuesData.seek(indexReader.get(blockIndex));
}
currentBlockIndex[0] = blockIndex;
if (bitsPerOrd == -1) {
decoder.decode(valuesData, currentBlock);
} else {
decoder.decodeOrdinals(valuesData, currentBlock, bitsPerOrd);
}
return currentBlock[blockInIndex];
}
return currentBlock[blockInIndex];
};
}

Expand Down