diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java b/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java index ca6fd44af50..a05ecee8a1e 100644 --- a/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java +++ b/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.ranking; +import com.yahoo.processing.request.CompoundName; import com.yahoo.search.query.Ranking; import com.yahoo.search.query.profile.types.FieldDescription; import com.yahoo.search.query.profile.types.QueryProfileType; @@ -21,6 +22,10 @@ public class SoftTimeout implements Cloneable { public static final String FACTOR = "factor"; public static final String TAILCOST = "tailcost"; + /** The full property name for turning softtimeout on or off */ + public static final CompoundName enableProperty = + CompoundName.fromComponents(Ranking.RANKING, Ranking.SOFTTIMEOUT, ENABLE); + static { argumentType = new QueryProfileType(Ranking.SOFTTIMEOUT); argumentType.setStrict(true); @@ -31,14 +36,15 @@ public class SoftTimeout implements Cloneable { } public static QueryProfileType getArgumentType() { return argumentType; } - public Boolean enable = null; + private boolean enabled = true; private Double factor = null; private Double tailcost = null; - public void setEnable(boolean enable) { this.enable = enable; } + public void setEnable(boolean enable) { this.enabled = enable; } - public Boolean getEnable() { return enable; } + public Boolean getEnable() { return enabled; } + /** Override the adaptive factor determined on the content nodes */ public void setFactor(double factor) { if ((factor < 0.0) || (factor > 1.0)) { throw new IllegalArgumentException("factor must be in the range [0.0, 1.0], got " + factor); @@ -48,6 +54,7 @@ public class SoftTimeout implements Cloneable { public Double getFactor() { return factor; } + /** Override the tail cost factor determined on the content nodes */ public void setTailcost(double tailcost) { if ((tailcost < 0.0) || (tailcost > 1.0)) { throw new IllegalArgumentException("tailcost must be in the range [0.0, 1.0], got " + tailcost); @@ -59,15 +66,13 @@ public class SoftTimeout implements Cloneable { /** Internal operation - DO NOT USE */ public void prepare(RankProperties rankProperties) { - if (enable != null) { - rankProperties.put("vespa.softtimeout.enable", String.valueOf(enable)); - } - if (factor != null) { + if ( !enabled) return; + + rankProperties.put("vespa.softtimeout.enable", "true"); + if (factor != null) rankProperties.put("vespa.softtimeout.factor", String.valueOf(factor)); - } - if (tailcost != null) { + if (tailcost != null) rankProperties.put("vespa.softtimeout.tailcost", String.valueOf(tailcost)); - } } @Override @@ -83,7 +88,7 @@ public class SoftTimeout implements Cloneable { @Override public int hashCode() { int hash = 0; - if (enable != null) hash += 11 * enable.hashCode(); + if (enabled) hash += 11; if (factor != null) hash += 13 * factor.hashCode(); if (tailcost != null) hash += 17 * tailcost.hashCode(); return hash; @@ -95,7 +100,7 @@ public class SoftTimeout implements Cloneable { if ( ! (o instanceof SoftTimeout)) return false; SoftTimeout other = (SoftTimeout)o; - if ( ! Objects.equals(this.enable, other.enable)) return false; + if ( ! Objects.equals(this.enabled, other.enabled)) return false; if ( ! Objects.equals(this.factor, other.factor)) return false; if ( ! Objects.equals(this.tailcost, other.tailcost)) return false; return true; |