Skip to content

Commit

Permalink
Add String comparison with CityHashKey and fix test failures (PR #13
Browse files Browse the repository at this point in the history
…by Rene)

Add String comparison with CityHashKey and fix test failures
  • Loading branch information
cheenamalhotra committed Jul 3, 2018
2 parents b4759e3 + d20e5d5 commit 8f8067e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static class CityHash128Key implements java.io.Serializable {
* Always refresh SerialVersionUID when prompted
*/
private static final long serialVersionUID = 166788428640603097L;
String unhashedString;
private long[] segments;
private int hashCode;

Expand All @@ -138,6 +139,7 @@ static class CityHash128Key implements java.io.Serializable {
}

CityHash128Key(String s) {
unhashedString = s;
byte[] bytes = new byte[s.length()];
s.getBytes(0, s.length(), bytes, 0);
segments = CityHash.cityHash128(bytes, 0, bytes.length);
Expand All @@ -147,7 +149,8 @@ public boolean equals(Object obj) {
if (!(obj instanceof CityHash128Key))
return false;

return java.util.Arrays.equals(segments, ((CityHash128Key) obj).segments);
return (java.util.Arrays.equals(segments, ((CityHash128Key) obj).segments)//checks if hash is equal, short-circuitting;
&& this.unhashedString.equals(((CityHash128Key) obj).unhashedString));//checks if string is equal
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ String getClassNameInternal() {
userSQL = parsedSQL.processedSQL;
userSQLParamPositions = parsedSQL.parameterPositions;
initParams(userSQLParamPositions.length);
useBulkCopyForBatchInsert = conn.getUseBulkCopyForBatchInsert();
}

/**
Expand Down

0 comments on commit 8f8067e

Please sign in to comment.