aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java
index a585c989954..be5b4242042 100644
--- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java
+++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java
@@ -5,6 +5,10 @@ import com.yahoo.javacc.UnicodeUtilities;
import com.yahoo.searchlib.rankingexpression.rule.Function;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
+import net.jpountz.xxhash.XXHash64;
+import net.jpountz.xxhash.XXHashFactory;
+
+import java.nio.charset.StandardCharsets;
/**
* A string value.
@@ -31,10 +35,15 @@ public class StringValue extends Value {
@Override
public TensorType type() { return TensorType.empty; }
- /** Returns the hashcode of this, to enable strings to be encoded (with reasonable safely) as doubles for optimization */
+ /**
+ * Returns the XXHash hashcode of this, to enable strings to be encoded (with reasonable safely)
+ * as doubles for optimization.
+ */
@Override
public double asDouble() {
- return value.hashCode();
+ XXHash64 hasher = XXHashFactory.fastestInstance().hash64();
+ byte[] data = value.getBytes(StandardCharsets.UTF_8);
+ return Double.longBitsToDouble(hasher.hash(data, 0, data.length, 0));
}
@Override