Skip to content

Commit

Permalink
Fix backport error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaih committed May 22, 2023
1 parent 25a908d commit 3eb7b04
Showing 1 changed file with 55 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1014,31 +1014,35 @@ public void testOnHeapHnswGraphSearch()
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();
}
Expand All @@ -1052,29 +1056,35 @@ public void testOnHeapHnswGraphSearch()
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);
}
Expand Down

0 comments on commit 3eb7b04

Please sign in to comment.