Skip to content

Commit

Permalink
Don't use segment hashCode in MemorySegmentVectorFloat, as it depends…
Browse files Browse the repository at this point in the history
… on segment base/offset in the heap rather than contents. This breaks testing around PQVectors hashcodes.
  • Loading branch information
jkni committed Dec 3, 2024
1 parent e2a4ad1 commit 90e84a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public boolean equals(Object o)
@Override
public int hashCode()
{
return Arrays.hashCode(data);
return this.getHashCode();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ default int offset(int i) {
void set(int i, float value);

void zero();

default int getHashCode() {
int result = 1;
for (int i = 0; i < length(); i++) {
if (get(i) != 0) {
result = 31 * result + Float.hashCode(get(i));
}
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ public boolean equals(Object o)

@Override
public int hashCode() {
return segment.hashCode();
return this.getHashCode();
}
}

0 comments on commit 90e84a9

Please sign in to comment.