From 4dcf56a06e955052bf0241c22032b5d58c5e9024 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Mon, 30 Apr 2018 14:48:16 +0200 Subject: [PATCH] Make the hashCode64 and updateHash features of the Value type rather than the AnyValue type. --- .../src/main/java/org/neo4j/values/AnyValue.java | 11 ----------- .../src/main/java/org/neo4j/values/VirtualValue.java | 7 ------- .../main/java/org/neo4j/values/storable/Value.java | 10 ++++++++++ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/community/values/src/main/java/org/neo4j/values/AnyValue.java b/community/values/src/main/java/org/neo4j/values/AnyValue.java index b3255908bf30e..67e8311ae638e 100644 --- a/community/values/src/main/java/org/neo4j/values/AnyValue.java +++ b/community/values/src/main/java/org/neo4j/values/AnyValue.java @@ -19,8 +19,6 @@ */ package org.neo4j.values; -import org.neo4j.hashing.HashFunction; - public abstract class AnyValue { private int hash; @@ -46,19 +44,10 @@ public final int hashCode() return hash; } - public final long hashCode64() - { - HashFunction xxh64 = HashFunction.incrementalXXH64(); - long seed = 1; // Arbitrary seed, but it must always be the same or hash values will change. - return xxh64.finalise( updateHash( xxh64, xxh64.initialise( seed ) ) ); - } - protected abstract boolean eq( Object other ); protected abstract int computeHash(); - public abstract long updateHash( HashFunction hashFunction, long hash ); - public abstract void writeTo( AnyValueWriter writer ) throws E; public boolean isSequenceValue() diff --git a/community/values/src/main/java/org/neo4j/values/VirtualValue.java b/community/values/src/main/java/org/neo4j/values/VirtualValue.java index 88c2cba0724ab..b1f8f3620d3c9 100644 --- a/community/values/src/main/java/org/neo4j/values/VirtualValue.java +++ b/community/values/src/main/java/org/neo4j/values/VirtualValue.java @@ -21,7 +21,6 @@ import java.util.Comparator; -import org.neo4j.hashing.HashFunction; import org.neo4j.values.virtual.VirtualValueGroup; import static org.neo4j.values.storable.Values.NO_VALUE; @@ -70,10 +69,4 @@ public Boolean ternaryEquals( AnyValue other ) public abstract VirtualValueGroup valueGroup(); public abstract int compareTo( VirtualValue other, Comparator comparator ); - - @Override - public long updateHash( HashFunction hashFunction, long hash ) - { - return hashFunction.update( hash, hashCode() ); - } } diff --git a/community/values/src/main/java/org/neo4j/values/storable/Value.java b/community/values/src/main/java/org/neo4j/values/storable/Value.java index d46ca0eb4f3b7..093d0def77ef2 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/Value.java +++ b/community/values/src/main/java/org/neo4j/values/storable/Value.java @@ -28,6 +28,7 @@ import java.util.regex.Pattern; import org.neo4j.graphdb.spatial.Geometry; +import org.neo4j.hashing.HashFunction; import org.neo4j.values.AnyValue; import org.neo4j.values.AnyValueWriter; import org.neo4j.values.Comparison; @@ -229,6 +230,15 @@ public Object asObject() public abstract NumberType numberType(); + public final long hashCode64() + { + HashFunction xxh64 = HashFunction.incrementalXXH64(); + long seed = 1; // Arbitrary seed, but it must always be the same or hash values will change. + return xxh64.finalise( updateHash( xxh64, xxh64.initialise( seed ) ) ); + } + + public abstract long updateHash( HashFunction hashFunction, long hash ); + public boolean isNaN() { return false;