aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-05-09 17:36:09 +0200
committerGitHub <noreply@github.com>2022-05-09 17:36:09 +0200
commit7ed5e488900a85e681432b1b1a17128fcc2085c5 (patch)
tree1d98d852d8fab21908f7ea2c1f80da78be5e0157
parent6cbbe5aa211a3406ad56990029b857b96192e8a9 (diff)
parent97d287e360fff66af6400ce217d668c16df8d16e (diff)
Merge pull request #22517 from vespa-engine/balder/deterministic-rank-expressions-config
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java6
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/LargeRankExpressions.java9
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java3
4 files changed, 13 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java b/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
index e134b8f53ac..11c55521100 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
@@ -8,7 +8,7 @@ import com.yahoo.path.Path;
import java.nio.ByteBuffer;
import java.util.Objects;
-public class DistributableResource {
+public class DistributableResource implements Comparable <DistributableResource> {
public enum PathType { FILE, URI, BLOB }
@@ -87,4 +87,8 @@ public class DistributableResource {
return "resource '" + name + " of type '" + pathType + "' with ref '" + fileReference + "'";
}
+ @Override
+ public int compareTo(DistributableResource o) {
+ return name.compareTo(o.getName());
+ }
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/LargeRankExpressions.java b/config-model/src/main/java/com/yahoo/searchdefinition/LargeRankExpressions.java
index a1299c12307..41ed2cbe999 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/LargeRankExpressions.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/LargeRankExpressions.java
@@ -3,9 +3,10 @@ package com.yahoo.searchdefinition;
import com.yahoo.config.application.api.FileRegistry;
-import java.util.Collections;
+import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
public class LargeRankExpressions {
private final Map<String, RankExpressionBody> expressions = new ConcurrentHashMap<>();
@@ -36,9 +37,9 @@ public class LargeRankExpressions {
}
public int limit() { return limit; }
- /** Returns a read-only map of the ranking constants in this indexed by name */
- public Map<String, RankExpressionBody> asMap() {
- return Collections.unmodifiableMap(expressions);
+ /** Returns a read-only list of ranking constants ordered by name */
+ public Collection<RankExpressionBody> expressions() {
+ return expressions.values().stream().sorted().collect(Collectors.toUnmodifiableList());
}
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index cd94b4a7f6e..4c9e65f16c8 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -153,7 +153,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
}
public void getConfig(RankingExpressionsConfig.Builder builder) {
- largeRankExpressions.asMap().values().forEach((expr) -> builder.expression.add(new RankingExpressionsConfig.Expression.Builder().name(expr.getName()).fileref(expr.getFileReference())));
+ largeRankExpressions.expressions().forEach((expr) -> builder.expression.add(new RankingExpressionsConfig.Expression.Builder().name(expr.getName()).fileref(expr.getFileReference())));
}
public void getConfig(RankingConstantsConfig.Builder builder) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java
index ed943317a1f..b9b7f122d63 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java
@@ -153,8 +153,9 @@ public class RankSetupValidator extends Validator {
// Assist verify-ranksetup in finding the actual ONNX model files
writeExtraVerifyRankSetupConfig(config, db.getDerivedConfiguration().getSchema().onnxModels().asMap().values());
- writeExtraVerifyRankSetupConfig(config, db.getDerivedConfiguration().getSchema().rankExpressionFiles().asMap().values());
+ writeExtraVerifyRankSetupConfig(config, db.getDerivedConfiguration().getSchema().rankExpressionFiles().expressions());
+ config.sort(String::compareTo);
String configContent = config.isEmpty() ? "" : StringUtilities.implodeMultiline(config);
IOUtils.writeFile(dir + "verify-ranksetup.cfg", configContent, false);
}