@@ -617,55 +617,36 @@ public String toString() {
617617 }
618618
619619 private static class BlockAwareSingletonDoubles extends BlockDocValuesReader {
620- private final BlockAwareNumericDocValues docValues ;
620+ private final BlockAwareNumericDocValues blockAware ;
621621 private final ToDouble toDouble ;
622- private int docID = -1 ;
623622
624- BlockAwareSingletonDoubles (BlockAwareNumericDocValues docValues , ToDouble toDouble ) {
625- this .docValues = docValues ;
623+ BlockAwareSingletonDoubles (BlockAwareNumericDocValues blockAware , ToDouble toDouble ) {
624+ this .blockAware = blockAware ;
626625 this .toDouble = toDouble ;
627626 }
628627
629628 @ Override
630629 public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
631630 try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count ())) {
632- int lastDoc = -1 ;
633- for (int i = 0 ; i < docs .count (); i ++) {
634- int doc = docs .get (i );
635- if (doc < lastDoc ) {
636- throw new IllegalStateException ("docs within same block must be in order" );
637- }
638- if (docValues .advanceExact (doc )) {
639- builder .appendDouble (toDouble .convert (docValues .longValue ()));
640- } else {
641- builder .appendNull ();
642- }
643- lastDoc = doc ;
644- this .docID = doc ;
645- }
631+ blockAware .loadBlock (builder , docs , toDouble );
646632 return builder .build ();
647633 }
648634 }
649635
650636 @ Override
651637 public void read (int docId , BlockLoader .StoredFields storedFields , Builder builder ) throws IOException {
652- this .docID = docId ;
653638 DoubleBuilder blockBuilder = (DoubleBuilder ) builder ;
654- if (docValues .advanceExact (this .docID )) {
655- blockBuilder .appendDouble (toDouble .convert (docValues .longValue ()));
656- } else {
657- blockBuilder .appendNull ();
658- }
639+ blockAware .loadDoc (blockBuilder , docId , toDouble );
659640 }
660641
661642 @ Override
662643 public int docId () {
663- return docID ;
644+ return blockAware . docID () ;
664645 }
665646
666647 @ Override
667648 public String toString () {
668- return "BlockDocValuesReader.SingletonDoubles " ;
649+ return "BlockDocValuesReader.BlockAwareSingletonDoubles " ;
669650 }
670651 }
671652
0 commit comments