@@ -1232,8 +1232,9 @@ private static void readTermDict(IndexInput meta, TermsDictEntry entry) throws I
1232
1232
entry .termsIndexAddressesLength = meta .readLong ();
1233
1233
}
1234
1234
1235
- private abstract static class NumericValues {
1236
- abstract long advance (long index ) throws IOException ;
1235
+ @ FunctionalInterface
1236
+ private interface NumericValues {
1237
+ long advance (long index ) throws IOException ;
1237
1238
}
1238
1239
1239
1240
static final class SortedOrdinalReader {
@@ -1603,30 +1604,26 @@ private NumericValues getValues(NumericEntry entry, final long maxOrd) throws IO
1603
1604
1604
1605
final IndexInput valuesData = data .slice ("values" , entry .valuesOffset , entry .valuesLength );
1605
1606
final int bitsPerOrd = maxOrd >= 0 ? PackedInts .bitsRequired (maxOrd - 1 ) : -1 ;
1606
- return new NumericValues () {
1607
1607
1608
- private final TSDBDocValuesEncoder decoder = new TSDBDocValuesEncoder (ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SIZE );
1609
- private long currentBlockIndex = -1 ;
1610
- private final long [] currentBlock = new long [ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SIZE ];
1611
-
1612
- @ Override
1613
- long advance (long index ) throws IOException {
1614
- final long blockIndex = index >>> ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SHIFT ;
1615
- final int blockInIndex = (int ) (index & ES819TSDBDocValuesFormat .NUMERIC_BLOCK_MASK );
1616
- if (blockIndex != currentBlockIndex ) {
1617
- // no need to seek if the loading block is the next block
1618
- if (currentBlockIndex + 1 != blockIndex ) {
1619
- valuesData .seek (indexReader .get (blockIndex ));
1620
- }
1621
- currentBlockIndex = blockIndex ;
1622
- if (bitsPerOrd == -1 ) {
1623
- decoder .decode (valuesData , currentBlock );
1624
- } else {
1625
- decoder .decodeOrdinals (valuesData , currentBlock , bitsPerOrd );
1626
- }
1608
+ final long [] currentBlockIndex = { -1 };
1609
+ final long [] currentBlock = new long [ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SIZE ];
1610
+ final TSDBDocValuesEncoder decoder = new TSDBDocValuesEncoder (ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SIZE );
1611
+ return index -> {
1612
+ final long blockIndex = index >>> ES819TSDBDocValuesFormat .NUMERIC_BLOCK_SHIFT ;
1613
+ final int blockInIndex = (int ) (index & ES819TSDBDocValuesFormat .NUMERIC_BLOCK_MASK );
1614
+ if (blockIndex != currentBlockIndex [0 ]) {
1615
+ // no need to seek if the loading block is the next block
1616
+ if (currentBlockIndex [0 ] + 1 != blockIndex ) {
1617
+ valuesData .seek (indexReader .get (blockIndex ));
1618
+ }
1619
+ currentBlockIndex [0 ] = blockIndex ;
1620
+ if (bitsPerOrd == -1 ) {
1621
+ decoder .decode (valuesData , currentBlock );
1622
+ } else {
1623
+ decoder .decodeOrdinals (valuesData , currentBlock , bitsPerOrd );
1627
1624
}
1628
- return currentBlock [blockInIndex ];
1629
1625
}
1626
+ return currentBlock [blockInIndex ];
1630
1627
};
1631
1628
}
1632
1629
0 commit comments