You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by pa...@apache.org on 2023/05/22 05:14:48 UTC

[lucene] branch branch_9x updated: Fix backport error

This is an automated email from the ASF dual-hosted git repository.

patrickz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 3eb7b040862 Fix backport error
3eb7b040862 is described below

commit 3eb7b0408628d16278dc99c12f6f8831ad250f17
Author: Patrick Zhai <zh...@gmail.com>
AuthorDate: Sun May 21 22:12:52 2023 -0700

    Fix backport error
---
 .../apache/lucene/util/hnsw/HnswGraphTestCase.java | 100 +++++++++++----------
 1 file changed, 55 insertions(+), 45 deletions(-)

diff --git a/lucene/core/src/test/org/apache/lucene/util/hnsw/HnswGraphTestCase.java b/lucene/core/src/test/org/apache/lucene/util/hnsw/HnswGraphTestCase.java
index 4cbcde3f362..a6ddb84f2da 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hnsw/HnswGraphTestCase.java
+++ b/lucene/core/src/test/org/apache/lucene/util/hnsw/HnswGraphTestCase.java
@@ -1014,31 +1014,35 @@ abstract class HnswGraphTestCase<T> extends LuceneTestCase {
     List<T> queries = new ArrayList<>();
     List<NeighborQueue> expects = new ArrayList<>();
     for (int i = 0; i < 100; i++) {
-      NeighborQueue expect;
+      NeighborQueue expect = null;
       T query = randomVector(dim);
       queries.add(query);
-      expect =
-          switch (getVectorEncoding()) {
-            case BYTE -> HnswGraphSearcher.search(
-                (byte[]) query,
-                100,
-                (RandomAccessVectorValues<byte[]>) vectors,
-                getVectorEncoding(),
-                similarityFunction,
-                hnsw,
-                acceptOrds,
-                Integer.MAX_VALUE);
-            case FLOAT32 -> HnswGraphSearcher.search(
-                (float[]) query,
-                100,
-                (RandomAccessVectorValues<float[]>) vectors,
-                getVectorEncoding(),
-                similarityFunction,
-                hnsw,
-                acceptOrds,
-                Integer.MAX_VALUE);
-          };
-
+      switch (getVectorEncoding()) {
+        case BYTE:
+          expect =
+              HnswGraphSearcher.search(
+                  (byte[]) query,
+                  100,
+                  (RandomAccessVectorValues<byte[]>) vectors,
+                  getVectorEncoding(),
+                  similarityFunction,
+                  hnsw,
+                  acceptOrds,
+                  Integer.MAX_VALUE);
+          break;
+        case FLOAT32:
+          expect =
+              HnswGraphSearcher.search(
+                  (float[]) query,
+                  100,
+                  (RandomAccessVectorValues<float[]>) vectors,
+                  getVectorEncoding(),
+                  similarityFunction,
+                  hnsw,
+                  acceptOrds,
+                  Integer.MAX_VALUE);
+      }
+      ;
       while (expect.size() > topK) {
         expect.pop();
       }
@@ -1052,29 +1056,35 @@ abstract class HnswGraphTestCase<T> extends LuceneTestCase {
       futures.add(
           exec.submit(
               () -> {
-                NeighborQueue actual;
+                NeighborQueue actual = null;
                 try {
-                  actual =
-                      switch (getVectorEncoding()) {
-                        case BYTE -> HnswGraphSearcher.search(
-                            (byte[]) query,
-                            100,
-                            (RandomAccessVectorValues<byte[]>) vectors,
-                            getVectorEncoding(),
-                            similarityFunction,
-                            hnsw,
-                            acceptOrds,
-                            Integer.MAX_VALUE);
-                        case FLOAT32 -> HnswGraphSearcher.search(
-                            (float[]) query,
-                            100,
-                            (RandomAccessVectorValues<float[]>) vectors,
-                            getVectorEncoding(),
-                            similarityFunction,
-                            hnsw,
-                            acceptOrds,
-                            Integer.MAX_VALUE);
-                      };
+
+                  switch (getVectorEncoding()) {
+                    case BYTE:
+                      actual =
+                          HnswGraphSearcher.search(
+                              (byte[]) query,
+                              100,
+                              (RandomAccessVectorValues<byte[]>) vectors,
+                              getVectorEncoding(),
+                              similarityFunction,
+                              hnsw,
+                              acceptOrds,
+                              Integer.MAX_VALUE);
+                      break;
+                    case FLOAT32:
+                      actual =
+                          HnswGraphSearcher.search(
+                              (float[]) query,
+                              100,
+                              (RandomAccessVectorValues<float[]>) vectors,
+                              getVectorEncoding(),
+                              similarityFunction,
+                              hnsw,
+                              acceptOrds,
+                              Integer.MAX_VALUE);
+                  }
+                  ;
                 } catch (IOException ioe) {
                   throw new RuntimeException(ioe);
                 }