summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-07-17 11:45:27 +0200
committerJon Bratseth <bratseth@gmail.com>2020-07-17 11:45:27 +0200
commit667eedc92b4c9c81c3872e000a8f26779b9bf131 (patch)
treed1ff7e4115c70877104c1f0e803417e50399f925 /container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
parent8dad7e25c8d1bd022880327a0c7f57e48efc302f (diff)
Faster lookup given many variants
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
index bc49e116c6e..d2c4eaaec9b 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
@@ -2,9 +2,9 @@
package com.yahoo.search.query.profile.compiled;
import com.yahoo.search.query.profile.DimensionValues;
-import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.types.QueryProfileType;
+import java.util.Objects;
import java.util.Optional;
/**
@@ -68,6 +68,24 @@ public class ValueWithSource {
public Optional<DimensionValues> variant() { return Optional.ofNullable(variant); }
@Override
+ public int hashCode() {
+ // Value is always a value object. Don't include source in identity.
+ return Objects.hash(value, isUnoverridable, type);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if ( ! (o instanceof ValueWithSource)) return false;
+
+ ValueWithSource other = (ValueWithSource)o;
+ if ( ! Objects.equals(this.value, other.value)) return false;
+ if ( ! Objects.equals(this.isUnoverridable, other.isUnoverridable)) return false;
+ if ( ! Objects.equals(this.type, other.type)) return false;
+ return true;
+ }
+
+ @Override
public String toString() {
return value +
" (from query profile '" + source + "'" +