Skip to content
Snippets Groups Projects
Commit bc36b0f1 authored by Wenchen Fan's avatar Wenchen Fan Committed by Davies Liu
Browse files

[SQL] [MINOR] speed up hashcode for UTF8String

similar to https://github.com/apache/spark/pull/10784, use `Murmur3_x86_32.hashUnsafeBytes` instead.

Author: Wenchen Fan <wenchen@databricks.com>

Closes #10791 from cloud-fan/string-hashcode.
parent 92502703
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ import com.esotericsoftware.kryo.io.Output;
import org.apache.spark.unsafe.Platform;
import org.apache.spark.unsafe.array.ByteArrayMethods;
import org.apache.spark.unsafe.hash.Murmur3_x86_32;
import static org.apache.spark.unsafe.Platform.*;
......@@ -935,11 +936,7 @@ public final class UTF8String implements Comparable<UTF8String>, Externalizable,
@Override
public int hashCode() {
int result = 1;
for (int i = 0; i < numBytes; i ++) {
result = 31 * result + getByte(i);
}
return result;
return Murmur3_x86_32.hashUnsafeBytes(base, offset, numBytes, 42);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment