@@ -124,10 +124,10 @@ private static class SingletonLongs extends BlockDocValuesReader {
124
124
}
125
125
126
126
@ Override
127
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
128
- try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count ())) {
127
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
128
+ try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count () - offset )) {
129
129
int lastDoc = -1 ;
130
- for (int i = 0 ; i < docs .count (); i ++) {
130
+ for (int i = offset ; i < docs .count (); i ++) {
131
131
int doc = docs .get (i );
132
132
if (doc < lastDoc ) {
133
133
throw new IllegalStateException ("docs within same block must be in order" );
@@ -173,9 +173,9 @@ private static class Longs extends BlockDocValuesReader {
173
173
}
174
174
175
175
@ Override
176
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
177
- try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count ())) {
178
- for (int i = 0 ; i < docs .count (); i ++) {
176
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
177
+ try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count () - offset )) {
178
+ for (int i = offset ; i < docs .count (); i ++) {
179
179
int doc = docs .get (i );
180
180
if (doc < this .docID ) {
181
181
throw new IllegalStateException ("docs within same block must be in order" );
@@ -259,10 +259,10 @@ private static class SingletonInts extends BlockDocValuesReader {
259
259
}
260
260
261
261
@ Override
262
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
263
- try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count ())) {
262
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
263
+ try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count () - offset )) {
264
264
int lastDoc = -1 ;
265
- for (int i = 0 ; i < docs .count (); i ++) {
265
+ for (int i = offset ; i < docs .count (); i ++) {
266
266
int doc = docs .get (i );
267
267
if (doc < lastDoc ) {
268
268
throw new IllegalStateException ("docs within same block must be in order" );
@@ -308,9 +308,9 @@ private static class Ints extends BlockDocValuesReader {
308
308
}
309
309
310
310
@ Override
311
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
312
- try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count ())) {
313
- for (int i = 0 ; i < docs .count (); i ++) {
311
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
312
+ try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count () - offset )) {
313
+ for (int i = offset ; i < docs .count (); i ++) {
314
314
int doc = docs .get (i );
315
315
if (doc < this .docID ) {
316
316
throw new IllegalStateException ("docs within same block must be in order" );
@@ -408,10 +408,10 @@ private static class SingletonDoubles extends BlockDocValuesReader {
408
408
}
409
409
410
410
@ Override
411
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
412
- try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count ())) {
411
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
412
+ try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count () - offset )) {
413
413
int lastDoc = -1 ;
414
- for (int i = 0 ; i < docs .count (); i ++) {
414
+ for (int i = offset ; i < docs .count (); i ++) {
415
415
int doc = docs .get (i );
416
416
if (doc < lastDoc ) {
417
417
throw new IllegalStateException ("docs within same block must be in order" );
@@ -461,9 +461,9 @@ private static class Doubles extends BlockDocValuesReader {
461
461
}
462
462
463
463
@ Override
464
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
465
- try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count ())) {
466
- for (int i = 0 ; i < docs .count (); i ++) {
464
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
465
+ try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count () - offset )) {
466
+ for (int i = offset ; i < docs .count (); i ++) {
467
467
int doc = docs .get (i );
468
468
if (doc < this .docID ) {
469
469
throw new IllegalStateException ("docs within same block must be in order" );
@@ -544,10 +544,10 @@ private static class DenseVectorValuesBlockReader extends BlockDocValuesReader {
544
544
}
545
545
546
546
@ Override
547
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
547
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
548
548
// Doubles from doc values ensures that the values are in order
549
- try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count (), dimensions )) {
550
- for (int i = 0 ; i < docs .count (); i ++) {
549
+ try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count () - offset , dimensions )) {
550
+ for (int i = offset ; i < docs .count (); i ++) {
551
551
int doc = docs .get (i );
552
552
if (doc < iterator .docID ()) {
553
553
throw new IllegalStateException ("docs within same block must be in order" );
@@ -645,19 +645,19 @@ private BlockLoader.Block readSingleDoc(BlockFactory factory, int docId) throws
645
645
if (ordinals .advanceExact (docId )) {
646
646
BytesRef v = ordinals .lookupOrd (ordinals .ordValue ());
647
647
// the returned BytesRef can be reused
648
- return factory .constantBytes (BytesRef .deepCopyOf (v ));
648
+ return factory .constantBytes (BytesRef .deepCopyOf (v ), 1 );
649
649
} else {
650
- return factory .constantNulls ();
650
+ return factory .constantNulls (1 );
651
651
}
652
652
}
653
653
654
654
@ Override
655
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
656
- if (docs .count () == 1 ) {
657
- return readSingleDoc (factory , docs .get (0 ));
655
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
656
+ if (docs .count () - offset == 1 ) {
657
+ return readSingleDoc (factory , docs .get (offset ));
658
658
}
659
- try (BlockLoader . SingletonOrdinalsBuilder builder = factory .singletonOrdinalsBuilder (ordinals , docs .count ())) {
660
- for (int i = 0 ; i < docs .count (); i ++) {
659
+ try (var builder = factory .singletonOrdinalsBuilder (ordinals , docs .count () - offset )) {
660
+ for (int i = offset ; i < docs .count (); i ++) {
661
661
int doc = docs .get (i );
662
662
if (doc < ordinals .docID ()) {
663
663
throw new IllegalStateException ("docs within same block must be in order" );
@@ -700,9 +700,9 @@ private static class Ordinals extends BlockDocValuesReader {
700
700
}
701
701
702
702
@ Override
703
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
704
- try (BytesRefBuilder builder = factory .bytesRefsFromDocValues (docs .count ())) {
705
- for (int i = 0 ; i < docs .count (); i ++) {
703
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
704
+ try (BytesRefBuilder builder = factory .bytesRefsFromDocValues (docs .count () - offset )) {
705
+ for (int i = offset ; i < docs .count (); i ++) {
706
706
int doc = docs .get (i );
707
707
if (doc < ordinals .docID ()) {
708
708
throw new IllegalStateException ("docs within same block must be in order" );
@@ -780,9 +780,9 @@ private static class BytesRefsFromBinary extends BlockDocValuesReader {
780
780
}
781
781
782
782
@ Override
783
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
784
- try (BlockLoader .BytesRefBuilder builder = factory .bytesRefs (docs .count ())) {
785
- for (int i = 0 ; i < docs .count (); i ++) {
783
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
784
+ try (BlockLoader .BytesRefBuilder builder = factory .bytesRefs (docs .count () - offset )) {
785
+ for (int i = offset ; i < docs .count (); i ++) {
786
786
int doc = docs .get (i );
787
787
if (doc < docID ) {
788
788
throw new IllegalStateException ("docs within same block must be in order" );
@@ -879,9 +879,9 @@ private static class DenseVectorFromBinary extends BlockDocValuesReader {
879
879
}
880
880
881
881
@ Override
882
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
883
- try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count (), dimensions )) {
884
- for (int i = 0 ; i < docs .count (); i ++) {
882
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
883
+ try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count () - offset , dimensions )) {
884
+ for (int i = offset ; i < docs .count (); i ++) {
885
885
int doc = docs .get (i );
886
886
if (doc < docID ) {
887
887
throw new IllegalStateException ("docs within same block must be in order" );
@@ -963,10 +963,10 @@ private static class SingletonBooleans extends BlockDocValuesReader {
963
963
}
964
964
965
965
@ Override
966
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
967
- try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count ())) {
966
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
967
+ try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count () - offset )) {
968
968
int lastDoc = -1 ;
969
- for (int i = 0 ; i < docs .count (); i ++) {
969
+ for (int i = offset ; i < docs .count (); i ++) {
970
970
int doc = docs .get (i );
971
971
if (doc < lastDoc ) {
972
972
throw new IllegalStateException ("docs within same block must be in order" );
@@ -1012,9 +1012,9 @@ private static class Booleans extends BlockDocValuesReader {
1012
1012
}
1013
1013
1014
1014
@ Override
1015
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
1016
- try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count ())) {
1017
- for (int i = 0 ; i < docs .count (); i ++) {
1015
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
1016
+ try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count () - offset )) {
1017
+ for (int i = offset ; i < docs .count (); i ++) {
1018
1018
int doc = docs .get (i );
1019
1019
if (doc < this .docID ) {
1020
1020
throw new IllegalStateException ("docs within same block must be in order" );
0 commit comments