Replace CityHash 1.1 with xxHash as the default hash function

This commit is contained in:
leventov
2015-11-28 23:31:25 +03:00
parent bfa9988551
commit 2d7e25985a
5 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -159,7 +159,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>zero-allocation-hashing</artifactId>
<version>0.2</version>
<version>0.4</version>
<scope>test</scope>
</dependency>
@@ -138,7 +138,7 @@ public interface Data<V> {
* <i>bytes</i> representation.
*/
default int dataHashCode() {
return (int) hash(LongHashFunction.city_1_1());
return (int) hash(LongHashFunction.xx_r39());
}
/**
@@ -29,7 +29,7 @@ public class InputKeyHashCode implements KeyHashCode {
public long keyHash = 0;
void initKeyHash() {
keyHash = ks.inputKey.hash(LongHashFunction.city_1_1());
keyHash = ks.inputKey.hash(LongHashFunction.xx_r39());
}
@Override
@@ -34,7 +34,7 @@ public class IterationKeyHashCode implements KeyHashCode {
void initKeyHash() {
long addr = s.tierBaseAddr + e.keyOffset;
long len = e.keySize;
keyHash = LongHashFunction.city_1_1().hashMemory(addr, len);
keyHash = LongHashFunction.xx_r39().hashMemory(addr, len);
}
@Override
@@ -56,7 +56,7 @@ public class KeySegmentDistributionTest {
for (int i = 0; i < size; i++) {
random.nextBytes(keyBytes);
String key = new String(keyBytes, StandardCharsets.US_ASCII);
long hash = LongHashFunction.city_1_1().hashBytes(StandardCharsets.UTF_8.encode(key));
long hash = LongHashFunction.xx_r39().hashBytes(StandardCharsets.UTF_8.encode(key));
int segmentIndex = (((int) hash) & Integer.MAX_VALUE) % segments;
// Put the segment index as a value to the map
map.put(key, segmentIndex);