summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-08-28 17:32:59 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-08-28 18:40:28 +0200
commit05f8000bc20236618ed7707efd9a4d0d5ff5bf68 (patch)
tree747f4080cda3cfda74263c8dbe2e5fc43ff17b14 /config-model/src/main/java
parentcedc58c11a3936ee643db817568cc43419564d78 (diff)
Control phrase execution with featureflag
Diffstat (limited to 'config-model/src/main/java')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java6
-rw-r--r--config-model/src/main/java/com/yahoo/schema/RankProfile.java45
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java17
3 files changed, 35 insertions, 33 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
index c2218cef684..57f01fd8f55 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
@@ -42,6 +42,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
private double defaultTermwiseLimit = 1.0;
private String jvmGCOptions = null;
private String queryDispatchPolicy = "adaptive";
+ private String phraseOptimization = "";
private String sequencerType = "THROUGHPUT";
private boolean firstTimeDeployment = false;
private String responseSequencerType = "ADAPTIVE";
@@ -151,6 +152,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
@Override public int rpcEventsBeforeWakeup() { return rpc_events_before_wakeup; }
@Override public String queryDispatchPolicy() { return queryDispatchPolicy; }
@Override public boolean useTwoPhaseDocumentGc() { return useTwoPhaseDocumentGc; }
+ @Override public String phraseOptimization() { return phraseOptimization; }
public TestProperties sharedStringRepoNoReclaim(boolean sharedStringRepoNoReclaim) {
@@ -200,6 +202,10 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
queryDispatchPolicy = policy;
return this;
}
+ public TestProperties setPhraseOptimization(String value) {
+ phraseOptimization = value;
+ return this;
+ }
public TestProperties setFeedSequencerType(String type) {
sequencerType = type;
return this;
diff --git a/config-model/src/main/java/com/yahoo/schema/RankProfile.java b/config-model/src/main/java/com/yahoo/schema/RankProfile.java
index 56786c733ec..acbfed30c4c 100644
--- a/config-model/src/main/java/com/yahoo/schema/RankProfile.java
+++ b/config-model/src/main/java/com/yahoo/schema/RankProfile.java
@@ -5,6 +5,7 @@ import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
import com.google.common.collect.ImmutableMap;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
+import com.yahoo.config.model.api.ModelContext;
import com.yahoo.path.Path;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.types.FieldDescription;
@@ -27,7 +28,6 @@ import com.yahoo.tensor.TensorType;
import java.io.IOException;
import java.io.Reader;
-import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
@@ -118,7 +118,7 @@ public class RankProfile implements Cloneable {
private Map<Reference, Constant> constants = new LinkedHashMap<>();
- private Map<String, OnnxModel> onnxModels = new LinkedHashMap<>();
+ private final Map<String, OnnxModel> onnxModels = new LinkedHashMap<>();
private Set<String> filterFields = new HashSet<>();
@@ -142,11 +142,9 @@ public class RankProfile implements Cloneable {
* and looking up rank profiles.
*/
public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry) {
- this.name = Objects.requireNonNull(name, "name cannot be null");
- this.schema = Objects.requireNonNull(schema, "schema cannot be null");
- this.rankProfileRegistry = rankProfileRegistry;
- this.applicationPackage = schema.applicationPackage();
- this.deployLogger = schema.getDeployLogger();
+ this(name, Objects.requireNonNull(schema, "schema cannot be null"),
+ schema.applicationPackage(), schema.getDeployLogger(),
+ schema.getDeployProperties(), rankProfileRegistry);
}
/**
@@ -154,13 +152,19 @@ public class RankProfile implements Cloneable {
*
* @param name the name of the new profile
*/
- public RankProfile(String name, ApplicationPackage applicationPackage, DeployLogger deployLogger,
- RankProfileRegistry rankProfileRegistry) {
+ public RankProfile(String name, Schema schema, ApplicationPackage applicationPackage, DeployLogger deployLogger,
+ ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry) {
this.name = Objects.requireNonNull(name, "name cannot be null");
- this.schema = null;
+ this.schema = schema;
this.rankProfileRegistry = rankProfileRegistry;
this.applicationPackage = applicationPackage;
this.deployLogger = deployLogger;
+ if (deployProperties.featureFlags().phraseOptimization().contains("split")) {
+ addRankProperty(new RankProperty("vespa.matching.split_unpacking_iterators", "true"));
+ }
+ if (deployProperties.featureFlags().phraseOptimization().contains("delay")) {
+ addRankProperty(new RankProperty("vespa.matching.delay_unpacking_iterators", "true"));
+ }
}
public String name() { return name; }
@@ -317,7 +321,7 @@ public class RankProfile implements Cloneable {
.filter(p -> nonEmptyValueFilter.test(p))
.collect(Collectors.toSet());
if (uniqueProperties.isEmpty()) return Optional.empty();
- if (uniqueProperties.size() == 1) return Optional.of(uniqueProperties.stream().findAny().get());
+ if (uniqueProperties.size() == 1) return uniqueProperties.stream().findAny();
throw new IllegalArgumentException("Only one of the profiles inherited by " + this + " can contain " +
propertyDescription + ", but it is present in multiple");
}
@@ -641,7 +645,7 @@ public class RankProfile implements Cloneable {
/** Returns a read only map view of the rank properties to use in this profile. This is never null. */
public Map<String, List<RankProperty>> getRankPropertyMap() {
- if (rankProperties.size() == 0 && inherited().isEmpty()) return Map.of();
+ if (rankProperties.isEmpty() && inherited().isEmpty()) return Map.of();
if (inherited().isEmpty()) return Collections.unmodifiableMap(rankProperties);
var inheritedProperties = uniquelyInherited(p -> p.getRankPropertyMap(), m -> ! m.isEmpty(), "rank-properties")
@@ -1148,7 +1152,7 @@ public class RankProfile implements Cloneable {
* A rank setting. The identity of a rank setting is its field name and type (not value).
* A rank setting is immutable.
*/
- public static class RankSetting implements Serializable {
+ public static class RankSetting {
private final String fieldName;
@@ -1222,13 +1226,10 @@ public class RankProfile implements Cloneable {
@Override
public boolean equals(Object object) {
- if (!(object instanceof RankSetting)) {
+ if (!(object instanceof RankSetting other)) {
return false;
}
- RankSetting other = (RankSetting)object;
- return
- fieldName.equals(other.fieldName) &&
- type.equals(other.type);
+ return fieldName.equals(other.fieldName) && type.equals(other.type);
}
@Override
@@ -1239,7 +1240,7 @@ public class RankProfile implements Cloneable {
}
/** A rank property. Rank properties are Value Objects */
- public static class RankProperty implements Serializable {
+ public static class RankProperty {
private final String name;
private final String value;
@@ -1260,8 +1261,7 @@ public class RankProfile implements Cloneable {
@Override
public boolean equals(Object object) {
- if (! (object instanceof RankProperty)) return false;
- RankProperty other=(RankProperty)object;
+ if (! (object instanceof RankProperty other)) return false;
return (other.name.equals(this.name) && other.value.equals(this.value));
}
@@ -1482,8 +1482,7 @@ public class RankProfile implements Cloneable {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! (o instanceof Constant)) return false;
- Constant other = (Constant)o;
+ if ( ! (o instanceof Constant other)) return false;
if ( ! other.name().equals(this.name())) return false;
if ( ! other.type().equals(this.type())) return false;
if ( ! other.value().equals(this.value())) return false;
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
index 7f5a78fa917..9bb03d3f07c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
@@ -17,10 +17,7 @@ import com.yahoo.config.model.ApplicationConfigProducerRoot;
import com.yahoo.config.model.ConfigModelRegistry;
import com.yahoo.config.model.ConfigModelRepo;
import com.yahoo.config.model.NullConfigModelRegistry;
-import com.yahoo.config.model.api.ApplicationClusterInfo;
-import com.yahoo.config.model.api.HostInfo;
-import com.yahoo.config.model.api.Model;
-import com.yahoo.config.model.api.Provisioned;
+import com.yahoo.config.model.api.*;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.config.model.producer.AbstractConfigProducerRoot;
@@ -61,7 +58,6 @@ import com.yahoo.vespa.model.utils.internal.ReflectionUtil;
import org.xml.sax.SAXException;
import java.io.IOException;
-import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.time.Instant;
import java.util.ArrayList;
@@ -96,9 +92,7 @@ import static java.util.stream.Collectors.toUnmodifiableMap;
*
* @author gjoranv
*/
-public final class VespaModel extends AbstractConfigProducerRoot implements Serializable, Model {
-
- private static final long serialVersionUID = 1L;
+public final class VespaModel extends AbstractConfigProducerRoot implements Model {
public static final Logger log = Logger.getLogger(VespaModel.class.getName());
@@ -264,11 +258,13 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
DeployLogger deployLogger = deployState.getDeployLogger();
RankProfileRegistry rankProfileRegistry = deployState.rankProfileRegistry();
QueryProfiles queryProfiles = deployState.getQueryProfiles();
+ ModelContext.Properties deployProperties = deployState.getProperties();
List <Future<ConvertedModel>> futureModels = new ArrayList<>();
if ( ! importedModels.isEmpty()) { // models/ directory is available
for (ImportedMlModel model : importedModels) {
// Due to automatic naming not guaranteeing unique names, there must be a 1-1 between OnnxModels and global RankProfiles.
- RankProfile profile = new RankProfile(model.name(), applicationPackage, deployLogger, rankProfileRegistry);
+ RankProfile profile = new RankProfile(model.name(), null, applicationPackage,
+ deployLogger, deployProperties, rankProfileRegistry);
addOnnxModelInfoFromSource(model, profile);
rankProfileRegistry.add(profile);
futureModels.add(deployState.getExecutor().submit(() -> {
@@ -285,7 +281,8 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
String modelName = generatedModelDir.getPath().last();
if (modelName.contains(".")) continue; // Name space: Not a global profile
// Due to automatic naming not guaranteeing unique names, there must be a 1-1 between OnnxModels and global RankProfiles.
- RankProfile profile = new RankProfile(modelName, applicationPackage, deployLogger, rankProfileRegistry);
+ RankProfile profile = new RankProfile(modelName, null, applicationPackage,
+ deployLogger, deployProperties, rankProfileRegistry);
addOnnxModelInfoFromStore(modelName, profile);
rankProfileRegistry.add(profile);
futureModels.add(deployState.getExecutor().submit(() -> {