@@ -123,10 +123,10 @@ private static class SingletonLongs extends BlockDocValuesReader {
123
123
}
124
124
125
125
@ Override
126
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
127
- try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count ())) {
126
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
127
+ try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count () - offset )) {
128
128
int lastDoc = -1 ;
129
- for (int i = 0 ; i < docs .count (); i ++) {
129
+ for (int i = offset ; i < docs .count (); i ++) {
130
130
int doc = docs .get (i );
131
131
if (doc < lastDoc ) {
132
132
throw new IllegalStateException ("docs within same block must be in order" );
@@ -172,9 +172,9 @@ private static class Longs extends BlockDocValuesReader {
172
172
}
173
173
174
174
@ Override
175
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
176
- try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count ())) {
177
- for (int i = 0 ; i < docs .count (); i ++) {
175
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
176
+ try (BlockLoader .LongBuilder builder = factory .longsFromDocValues (docs .count () - offset )) {
177
+ for (int i = offset ; i < docs .count (); i ++) {
178
178
int doc = docs .get (i );
179
179
if (doc < this .docID ) {
180
180
throw new IllegalStateException ("docs within same block must be in order" );
@@ -258,10 +258,10 @@ private static class SingletonInts extends BlockDocValuesReader {
258
258
}
259
259
260
260
@ Override
261
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
262
- try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count ())) {
261
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
262
+ try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count () - offset )) {
263
263
int lastDoc = -1 ;
264
- for (int i = 0 ; i < docs .count (); i ++) {
264
+ for (int i = offset ; i < docs .count (); i ++) {
265
265
int doc = docs .get (i );
266
266
if (doc < lastDoc ) {
267
267
throw new IllegalStateException ("docs within same block must be in order" );
@@ -307,9 +307,9 @@ private static class Ints extends BlockDocValuesReader {
307
307
}
308
308
309
309
@ Override
310
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
311
- try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count ())) {
312
- for (int i = 0 ; i < docs .count (); i ++) {
310
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
311
+ try (BlockLoader .IntBuilder builder = factory .intsFromDocValues (docs .count () - offset )) {
312
+ for (int i = offset ; i < docs .count (); i ++) {
313
313
int doc = docs .get (i );
314
314
if (doc < this .docID ) {
315
315
throw new IllegalStateException ("docs within same block must be in order" );
@@ -407,10 +407,10 @@ private static class SingletonDoubles extends BlockDocValuesReader {
407
407
}
408
408
409
409
@ Override
410
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
411
- try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count ())) {
410
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
411
+ try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count () - offset )) {
412
412
int lastDoc = -1 ;
413
- for (int i = 0 ; i < docs .count (); i ++) {
413
+ for (int i = offset ; i < docs .count (); i ++) {
414
414
int doc = docs .get (i );
415
415
if (doc < lastDoc ) {
416
416
throw new IllegalStateException ("docs within same block must be in order" );
@@ -460,9 +460,9 @@ private static class Doubles extends BlockDocValuesReader {
460
460
}
461
461
462
462
@ Override
463
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
464
- try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count ())) {
465
- for (int i = 0 ; i < docs .count (); i ++) {
463
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
464
+ try (BlockLoader .DoubleBuilder builder = factory .doublesFromDocValues (docs .count () - offset )) {
465
+ for (int i = offset ; i < docs .count (); i ++) {
466
466
int doc = docs .get (i );
467
467
if (doc < this .docID ) {
468
468
throw new IllegalStateException ("docs within same block must be in order" );
@@ -541,10 +541,10 @@ private static class DenseVectorValuesBlockReader extends BlockDocValuesReader {
541
541
}
542
542
543
543
@ Override
544
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
544
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
545
545
// Doubles from doc values ensures that the values are in order
546
- try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count (), dimensions )) {
547
- for (int i = 0 ; i < docs .count (); i ++) {
546
+ try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count () - offset , dimensions )) {
547
+ for (int i = offset ; i < docs .count (); i ++) {
548
548
int doc = docs .get (i );
549
549
if (doc < floatVectorValues .docID ()) {
550
550
throw new IllegalStateException ("docs within same block must be in order" );
@@ -642,19 +642,19 @@ private BlockLoader.Block readSingleDoc(BlockFactory factory, int docId) throws
642
642
if (ordinals .advanceExact (docId )) {
643
643
BytesRef v = ordinals .lookupOrd (ordinals .ordValue ());
644
644
// the returned BytesRef can be reused
645
- return factory .constantBytes (BytesRef .deepCopyOf (v ));
645
+ return factory .constantBytes (BytesRef .deepCopyOf (v ), 1 );
646
646
} else {
647
- return factory .constantNulls ();
647
+ return factory .constantNulls (1 );
648
648
}
649
649
}
650
650
651
651
@ Override
652
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
653
- if (docs .count () == 1 ) {
654
- return readSingleDoc (factory , docs .get (0 ));
652
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
653
+ if (docs .count () - offset == 1 ) {
654
+ return readSingleDoc (factory , docs .get (offset ));
655
655
}
656
- try (BlockLoader . SingletonOrdinalsBuilder builder = factory .singletonOrdinalsBuilder (ordinals , docs .count ())) {
657
- for (int i = 0 ; i < docs .count (); i ++) {
656
+ try (var builder = factory .singletonOrdinalsBuilder (ordinals , docs .count () - offset )) {
657
+ for (int i = offset ; i < docs .count (); i ++) {
658
658
int doc = docs .get (i );
659
659
if (doc < ordinals .docID ()) {
660
660
throw new IllegalStateException ("docs within same block must be in order" );
@@ -697,9 +697,9 @@ private static class Ordinals extends BlockDocValuesReader {
697
697
}
698
698
699
699
@ Override
700
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
701
- try (BytesRefBuilder builder = factory .bytesRefsFromDocValues (docs .count ())) {
702
- for (int i = 0 ; i < docs .count (); i ++) {
700
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
701
+ try (BytesRefBuilder builder = factory .bytesRefsFromDocValues (docs .count () - offset )) {
702
+ for (int i = offset ; i < docs .count (); i ++) {
703
703
int doc = docs .get (i );
704
704
if (doc < ordinals .docID ()) {
705
705
throw new IllegalStateException ("docs within same block must be in order" );
@@ -777,9 +777,9 @@ private static class BytesRefsFromBinary extends BlockDocValuesReader {
777
777
}
778
778
779
779
@ Override
780
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
781
- try (BlockLoader .BytesRefBuilder builder = factory .bytesRefs (docs .count ())) {
782
- for (int i = 0 ; i < docs .count (); i ++) {
780
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
781
+ try (BlockLoader .BytesRefBuilder builder = factory .bytesRefs (docs .count () - offset )) {
782
+ for (int i = offset ; i < docs .count (); i ++) {
783
783
int doc = docs .get (i );
784
784
if (doc < docID ) {
785
785
throw new IllegalStateException ("docs within same block must be in order" );
@@ -876,9 +876,9 @@ private static class DenseVectorFromBinary extends BlockDocValuesReader {
876
876
}
877
877
878
878
@ Override
879
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
880
- try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count (), dimensions )) {
881
- for (int i = 0 ; i < docs .count (); i ++) {
879
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
880
+ try (BlockLoader .FloatBuilder builder = factory .denseVectors (docs .count () - offset , dimensions )) {
881
+ for (int i = offset ; i < docs .count (); i ++) {
882
882
int doc = docs .get (i );
883
883
if (doc < docID ) {
884
884
throw new IllegalStateException ("docs within same block must be in order" );
@@ -960,10 +960,10 @@ private static class SingletonBooleans extends BlockDocValuesReader {
960
960
}
961
961
962
962
@ Override
963
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
964
- try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count ())) {
963
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
964
+ try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count () - offset )) {
965
965
int lastDoc = -1 ;
966
- for (int i = 0 ; i < docs .count (); i ++) {
966
+ for (int i = offset ; i < docs .count (); i ++) {
967
967
int doc = docs .get (i );
968
968
if (doc < lastDoc ) {
969
969
throw new IllegalStateException ("docs within same block must be in order" );
@@ -1009,9 +1009,9 @@ private static class Booleans extends BlockDocValuesReader {
1009
1009
}
1010
1010
1011
1011
@ Override
1012
- public BlockLoader .Block read (BlockFactory factory , Docs docs ) throws IOException {
1013
- try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count ())) {
1014
- for (int i = 0 ; i < docs .count (); i ++) {
1012
+ public BlockLoader .Block read (BlockFactory factory , Docs docs , int offset ) throws IOException {
1013
+ try (BlockLoader .BooleanBuilder builder = factory .booleansFromDocValues (docs .count () - offset )) {
1014
+ for (int i = offset ; i < docs .count (); i ++) {
1015
1015
int doc = docs .get (i );
1016
1016
if (doc < this .docID ) {
1017
1017
throw new IllegalStateException ("docs within same block must be in order" );
0 commit comments