@@ -1232,8 +1232,9 @@ private static void readTermDict(IndexInput meta, TermsDictEntry entry) throws I
12321232        entry .termsIndexAddressesLength  = meta .readLong ();
12331233    }
12341234
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 ;
12371238    }
12381239
12391240    static  final  class  SortedOrdinalReader  {
@@ -1603,30 +1604,26 @@ private NumericValues getValues(NumericEntry entry, final long maxOrd) throws IO
16031604
16041605        final  IndexInput  valuesData  = data .slice ("values" , entry .valuesOffset , entry .valuesLength );
16051606        final  int  bitsPerOrd  = maxOrd  >= 0  ? PackedInts .bitsRequired (maxOrd  - 1 ) : -1 ;
1606-         return  new  NumericValues () {
16071607
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 );
16271624                }
1628-                 return  currentBlock [blockInIndex ];
16291625            }
1626+             return  currentBlock [blockInIndex ];
16301627        };
16311628    }
16321629
0 commit comments