mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Replace CityHash 1.1 with xxHash as the default hash function
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user