@@ -130,48 +130,58 @@ public void testOrdToDocWithSparseVectors() throws IOException {
130130
131131 // After merge, the vector ordinals will be 0, 1, 2 but they correspond to docIds 1, 3, 4
132132 int totalDocs = 6 ;
133- int [] docIdsWithVectors = {1 , 3 , 4 }; // Document IDs that have vectors
133+ int [] docIdsWithVectors = { 1 , 3 , 4 }; // Document IDs that have vectors
134134 int numVectors = docIdsWithVectors .length ;
135135
136136 float [][] normalizedVectors = new float [numVectors ][];
137137 float [] magnitudes = new float [numVectors ];
138138
139- normalizedVectors [0 ] = new float []{ 0.6f , 0.8f , 0.0f , 0.0f }; // Doc 1
139+ normalizedVectors [0 ] = new float [] { 0.6f , 0.8f , 0.0f , 0.0f }; // Doc 1
140140 magnitudes [0 ] = 5.0f ;
141141
142- normalizedVectors [1 ] = new float []{ 1.0f , 0.0f , 0.0f , 0.0f }; // Doc 3
142+ normalizedVectors [1 ] = new float [] { 1.0f , 0.0f , 0.0f , 0.0f }; // Doc 3
143143 magnitudes [1 ] = 2.0f ;
144144
145- normalizedVectors [2 ] = new float []{ 0.0f , 0.0f , 0.6f , 0.8f }; // Doc 4
145+ normalizedVectors [2 ] = new float [] { 0.0f , 0.0f , 0.6f , 0.8f }; // Doc 4
146146 magnitudes [2 ] = 10.0f ;
147147
148148 // Expected original vectors after denormalization
149149 float [][] expectedVectors = new float [numVectors ][];
150- expectedVectors [0 ] = new float []{ 3.0f , 4.0f , 0.0f , 0.0f }; // Doc 1
151- expectedVectors [1 ] = new float []{ 2.0f , 0.0f , 0.0f , 0.0f }; // Doc 3
152- expectedVectors [2 ] = new float []{ 0.0f , 0.0f , 6.0f , 8.0f }; // Doc 4
150+ expectedVectors [0 ] = new float [] { 3.0f , 4.0f , 0.0f , 0.0f }; // Doc 1
151+ expectedVectors [1 ] = new float [] { 2.0f , 0.0f , 0.0f , 0.0f }; // Doc 3
152+ expectedVectors [2 ] = new float [] { 0.0f , 0.0f , 6.0f , 8.0f }; // Doc 4
153153
154154 // Create a custom FloatVectorValues that simulates post-merge sparse vector scenario
155155 FloatVectorValues sparseVectorValues = new FloatVectorValues () {
156156 @ Override
157- public int dimension () { return 4 ; }
157+ public int dimension () {
158+ return 4 ;
159+ }
158160
159161 @ Override
160- public int size () { return numVectors ; }
162+ public int size () {
163+ return numVectors ;
164+ }
161165
162166 @ Override
163167 public DocIndexIterator iterator () {
164168 return new DocIndexIterator () {
165169 private int index = -1 ;
166170
167171 @ Override
168- public int docID () { return index ; }
172+ public int docID () {
173+ return index ;
174+ }
169175
170176 @ Override
171- public int index () { return index ; }
177+ public int index () {
178+ return index ;
179+ }
172180
173181 @ Override
174- public int nextDoc () { return advance (index + 1 ); }
182+ public int nextDoc () {
183+ return advance (index + 1 );
184+ }
175185
176186 @ Override
177187 public int advance (int target ) {
@@ -180,15 +190,21 @@ public int advance(int target) {
180190 }
181191
182192 @ Override
183- public long cost () { return numVectors ; }
193+ public long cost () {
194+ return numVectors ;
195+ }
184196 };
185197 }
186198
187199 @ Override
188- public FloatVectorValues copy () { throw new UnsupportedOperationException (); }
200+ public FloatVectorValues copy () {
201+ throw new UnsupportedOperationException ();
202+ }
189203
190204 @ Override
191- public VectorScorer scorer (float [] floats ) { throw new UnsupportedOperationException (); }
205+ public VectorScorer scorer (float [] floats ) {
206+ throw new UnsupportedOperationException ();
207+ }
192208
193209 // This is the key method - it maps ordinals to actual document IDs
194210 @ Override
@@ -231,10 +247,14 @@ public boolean advanceExact(int target) {
231247 }
232248
233249 @ Override
234- public int docID () { return docId ; }
250+ public int docID () {
251+ return docId ;
252+ }
235253
236254 @ Override
237- public int nextDoc () { return advance (docId + 1 ); }
255+ public int nextDoc () {
256+ return advance (docId + 1 );
257+ }
238258
239259 @ Override
240260 public int advance (int target ) {
@@ -248,14 +268,13 @@ public int advance(int target) {
248268 }
249269
250270 @ Override
251- public long cost () { return totalDocs ; }
271+ public long cost () {
272+ return totalDocs ;
273+ }
252274 };
253275
254276 // Test the fixed version (with ordToDoc)
255- DenormalizedCosineFloatVectorValues vectorValues = new DenormalizedCosineFloatVectorValues (
256- sparseVectorValues ,
257- sparseMagnitudes
258- );
277+ DenormalizedCosineFloatVectorValues vectorValues = new DenormalizedCosineFloatVectorValues (sparseVectorValues , sparseMagnitudes );
259278
260279 // Test that ordToDoc method properly maps ordinals to document IDs
261280 KnnVectorValues .DocIndexIterator iterator = vectorValues .iterator ();
@@ -266,11 +285,7 @@ public int advance(int target) {
266285 // Verify that ordToDoc works correctly
267286 int expectedDocId = docIdsWithVectors [ord ];
268287 int actualDocId = vectorValues .ordToDoc (ord );
269- assertEquals (
270- "ordToDoc should correctly map ord " + ord + " to docId " + expectedDocId ,
271- expectedDocId ,
272- actualDocId
273- );
288+ assertEquals ("ordToDoc should correctly map ord " + ord + " to docId " + expectedDocId , expectedDocId , actualDocId );
274289
275290 // Get the denormalized vector - this relies on ordToDoc working correctly
276291 float [] actualVector = vectorValues .vectorValue (iterator .index ());
0 commit comments