Skip to content

Commit

Permalink
Add fast path for near vector search with list
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkkul committed Jul 4, 2024
1 parent ac8429c commit 8d95d60
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions weaviate/collections/grpc/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,20 @@ def near_vector(

targets, target_vectors = self.__target_vector_to_grpc(target_vector)

vector_per_target_tmp, near_vector_grpc = self.__vector_per_target(
near_vector, targets, "near_vector"
)
if (
isinstance(near_vector, list)
and len(near_vector) > 0
and isinstance(near_vector[0], float)
):
# fast path for simple vector
near_vector_grpc: Optional[bytes] = struct.pack(
"{}f".format(len(near_vector)), *near_vector
)
vector_per_target_tmp = None
else:
vector_per_target_tmp, near_vector_grpc = self.__vector_per_target(
near_vector, targets, "near_vector"
)
request = self.__create_request(
limit=limit,
offset=offset,
Expand Down

0 comments on commit 8d95d60

Please sign in to comment.