@@ -577,6 +577,9 @@ public void read(int docId, BlockLoader.StoredFields storedFields, Builder build
577577 }
578578
579579 private void read (int doc , BlockLoader .FloatBuilder builder ) throws IOException {
580+ assert vectorValues .dimension () == dimensions
581+ : "unexpected dimensions for vector value; expected " + dimensions + " but got " + vectorValues .dimension ();
582+
580583 if (iterator .docID () > doc ) {
581584 builder .appendNull ();
582585 } else if (iterator .docID () == doc || iterator .advance (doc ) == doc ) {
@@ -604,8 +607,6 @@ private static class FloatDenseVectorValuesBlockReader extends DenseVectorValues
604607
605608 protected void appendDoc (BlockLoader .FloatBuilder builder ) throws IOException {
606609 float [] floats = vectorValues .vectorValue (iterator .index ());
607- assert floats .length == dimensions
608- : "unexpected dimensions for vector value; expected " + dimensions + " but got " + floats .length ;
609610 for (float aFloat : floats ) {
610611 builder .appendFloat (aFloat );
611612 }
@@ -631,16 +632,13 @@ private static class FloatDenseVectorNormalizedValuesBlockReader extends DenseVe
631632
632633 @ Override
633634 protected void appendDoc (BlockLoader .FloatBuilder builder ) throws IOException {
634- float [] floats = vectorValues .vectorValue (iterator .index ());
635- assert floats .length == dimensions
636- : "unexpected dimensions for vector value; expected " + dimensions + " but got " + floats .length ;
637-
638635 float magnitude = 1.0f ;
639636 // If all vectors are normalized, no doc values will be present. The vector may be normalized already, so we may not have a
640637 // stored magnitude for all docs
641638 if ((magnitudeDocValues != null ) && magnitudeDocValues .advanceExact (iterator .docID ())) {
642639 magnitude = Float .intBitsToFloat ((int ) magnitudeDocValues .longValue ());
643640 }
641+ float [] floats = vectorValues .vectorValue (iterator .index ());
644642 for (float aFloat : floats ) {
645643 builder .appendFloat (aFloat * magnitude );
646644 }
0 commit comments