Skip to content

Commit

Permalink
Make the hashCode64 and updateHash features of the Value type rather …
Browse files Browse the repository at this point in the history
…than the AnyValue type.
  • Loading branch information
chrisvest committed Apr 30, 2018
1 parent 675fef4 commit 4dcf56a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
11 changes: 0 additions & 11 deletions community/values/src/main/java/org/neo4j/values/AnyValue.java
Expand Up @@ -19,8 +19,6 @@
*/ */
package org.neo4j.values; package org.neo4j.values;


import org.neo4j.hashing.HashFunction;

public abstract class AnyValue public abstract class AnyValue
{ {
private int hash; private int hash;
Expand All @@ -46,19 +44,10 @@ public final int hashCode()
return hash; 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 boolean eq( Object other );


protected abstract int computeHash(); protected abstract int computeHash();


public abstract long updateHash( HashFunction hashFunction, long hash );

public abstract <E extends Exception> void writeTo( AnyValueWriter<E> writer ) throws E; public abstract <E extends Exception> void writeTo( AnyValueWriter<E> writer ) throws E;


public boolean isSequenceValue() public boolean isSequenceValue()
Expand Down
Expand Up @@ -21,7 +21,6 @@


import java.util.Comparator; import java.util.Comparator;


import org.neo4j.hashing.HashFunction;
import org.neo4j.values.virtual.VirtualValueGroup; import org.neo4j.values.virtual.VirtualValueGroup;


import static org.neo4j.values.storable.Values.NO_VALUE; import static org.neo4j.values.storable.Values.NO_VALUE;
Expand Down Expand Up @@ -70,10 +69,4 @@ public Boolean ternaryEquals( AnyValue other )
public abstract VirtualValueGroup valueGroup(); public abstract VirtualValueGroup valueGroup();


public abstract int compareTo( VirtualValue other, Comparator<AnyValue> comparator ); public abstract int compareTo( VirtualValue other, Comparator<AnyValue> comparator );

@Override
public long updateHash( HashFunction hashFunction, long hash )
{
return hashFunction.update( hash, hashCode() );
}
} }
Expand Up @@ -28,6 +28,7 @@
import java.util.regex.Pattern; import java.util.regex.Pattern;


import org.neo4j.graphdb.spatial.Geometry; import org.neo4j.graphdb.spatial.Geometry;
import org.neo4j.hashing.HashFunction;
import org.neo4j.values.AnyValue; import org.neo4j.values.AnyValue;
import org.neo4j.values.AnyValueWriter; import org.neo4j.values.AnyValueWriter;
import org.neo4j.values.Comparison; import org.neo4j.values.Comparison;
Expand Down Expand Up @@ -229,6 +230,15 @@ public Object asObject()


public abstract NumberType numberType(); 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() public boolean isNaN()
{ {
return false; return false;
Expand Down

0 comments on commit 4dcf56a

Please sign in to comment.