Skip to content

Commit

Permalink
Addressing review
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaporciani committed Jun 13, 2023
1 parent 901febe commit 7219987
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import org.apache.lucene.index.ByteVectorValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
Expand Down Expand Up @@ -65,14 +66,15 @@ protected DocIdSetIterator getVectorIterator() {

@Override
public boolean equals(Object o) {
if (o.getClass() != ByteKnnVectorFieldSource.class) return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ByteKnnVectorFieldSource other = (ByteKnnVectorFieldSource) o;
return fieldName.equals(other.fieldName);
return Objects.equals(fieldName, other.fieldName);
}

@Override
public int hashCode() {
return getClass().hashCode() * 31 + fieldName.getClass().hashCode();
return getClass().hashCode() * 31 + Objects.hashCode(fieldName);

This comment has been minimized.

Copy link
@uschindler

uschindler Jun 13, 2023

Contributor

Sorry I meant: return Objects.hash(getClass(), fieldName);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public String toString(int doc) throws IOException {

@Override
public boolean equals(Object o) {
if (!(o instanceof ConstKnnByteVectorValueSource)) return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConstKnnByteVectorValueSource other = (ConstKnnByteVectorValueSource) o;
return Arrays.equals(vector, other.vector);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public String toString(int doc) throws IOException {

@Override
public boolean equals(Object o) {
if (!(o instanceof ConstKnnFloatValueSource)) return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConstKnnFloatValueSource other = (ConstKnnFloatValueSource) o;
return Arrays.equals(vector, other.vector);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import org.apache.lucene.index.FloatVectorValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
Expand Down Expand Up @@ -64,14 +65,15 @@ protected DocIdSetIterator getVectorIterator() {

@Override
public boolean equals(Object o) {
if (o.getClass() != FloatKnnVectorFieldSource.class) return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FloatKnnVectorFieldSource other = (FloatKnnVectorFieldSource) o;
return fieldName.equals(other.fieldName);
return Objects.equals(fieldName, other.fieldName);
}

@Override
public int hashCode() {
return getClass().hashCode() * 31 + fieldName.getClass().hashCode();
return getClass().hashCode() * 31 + Objects.hashCode(fieldName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
Expand Down Expand Up @@ -72,17 +73,17 @@ public String toString(int doc) throws IOException {

@Override
public boolean equals(Object o) {
return o instanceof VectorSimilarityFunction
&& similarityFunction.equals(((VectorSimilarityFunction) o).similarityFunction)
&& vector1.equals(((VectorSimilarityFunction) o).vector1)
&& vector2.equals(((VectorSimilarityFunction) o).vector2);
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return Objects.equals(vector1, ((VectorSimilarityFunction) o).vector1)
&& Objects.equals(vector2, ((VectorSimilarityFunction) o).vector2);
}

@Override
public int hashCode() {
int h = similarityFunction.hashCode();
h = 31 * h + vector1.hashCode();
h = 31 * h + vector2.hashCode();
h = 31 * h + Objects.hashCode(vector1);
h = 31 * h + Objects.hashCode(vector2);
return h;
}

Expand Down

0 comments on commit 7219987

Please sign in to comment.