From a256de9e2af66c072da8df19761e69bf3cb7bb70 Mon Sep 17 00:00:00 2001 From: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com> Date: Wed, 11 Dec 2024 07:50:30 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Benjamin Trent --- .../mapper/vectors/VectorSimilarityFloatValueSource.java | 4 ++-- .../elasticsearch/search/vectors/RescoreKnnVectorQuery.java | 2 +- .../elasticsearch/search/vectors/RescoreVectorBuilder.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java b/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java index 04b2a906d6dad..74a7dbe168e6b 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java @@ -89,13 +89,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; VectorSimilarityFloatValueSource that = (VectorSimilarityFloatValueSource) o; return Objects.equals(field, that.field) - && Objects.deepEquals(target, that.target) + && Arrays.equals(target, that.target) && vectorSimilarityFunction == that.vectorSimilarityFunction; } @Override public String toString() { - return "VectorSimilarityFloatValueSource(" + field + ", " + Arrays.toString(target) + ", " + vectorSimilarityFunction + ")"; + return "VectorSimilarityFloatValueSource(" + field + ", [" + target[0] + ",...], " + vectorSimilarityFunction + ")"; } @Override diff --git a/server/src/main/java/org/elasticsearch/search/vectors/RescoreKnnVectorQuery.java b/server/src/main/java/org/elasticsearch/search/vectors/RescoreKnnVectorQuery.java index 014c3265c1833..a9c606b1f8618 100644 --- a/server/src/main/java/org/elasticsearch/search/vectors/RescoreKnnVectorQuery.java +++ b/server/src/main/java/org/elasticsearch/search/vectors/RescoreKnnVectorQuery.java @@ -109,7 +109,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; RescoreKnnVectorQuery that = (RescoreKnnVectorQuery) o; return Objects.equals(fieldName, that.fieldName) - && Objects.deepEquals(floatTarget, that.floatTarget) + && Arrays.equals(floatTarget, that.floatTarget) && vectorSimilarityFunction == that.vectorSimilarityFunction && Objects.equals(k, that.k) && Objects.equals(innerQuery, that.innerQuery); diff --git a/server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java b/server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java index 5c1abd15989ee..4604d4f0ea325 100644 --- a/server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java @@ -37,7 +37,7 @@ public class RescoreVectorBuilder implements Writeable, ToXContentObject { // Oversample is required as of now as it is the only field in the rescore vector private final float numCandidatesFactor; - public RescoreVectorBuilder(Float numCandidatesFactor) { + public RescoreVectorBuilder(float numCandidatesFactor) { Objects.requireNonNull(numCandidatesFactor, "[" + NUM_CANDIDATES_FACTOR_FIELD.getPreferredName() + "] must be set"); if (numCandidatesFactor < MIN_OVERSAMPLE) { throw new IllegalArgumentException("[" + NUM_CANDIDATES_FACTOR_FIELD.getPreferredName() + "] must be >= " + MIN_OVERSAMPLE); @@ -79,7 +79,7 @@ public int hashCode() { return Objects.hashCode(numCandidatesFactor); } - public Float numCandidatesFactor() { + public float numCandidatesFactor() { return numCandidatesFactor; } }