summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-08-30 16:46:29 +0200
committerGitHub <noreply@github.com>2018-08-30 16:46:29 +0200
commitd073e0575c1c4a516615219c5e8732b886eb8d85 (patch)
treee12cc864b1f22f05ef7810cd97005c7c006a2829 /searchlib
parentcef4c0f9d7c084f320e77abb2a93522acd7f3f53 (diff)
Revert "Bratseth/generate rank profiles for all models part 10 2"
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java24
-rw-r--r--searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java18
2 files changed, 17 insertions, 25 deletions
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java
index f7fe91cb56f..6716993e1dd 100644
--- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java
+++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java
@@ -98,33 +98,33 @@ public class ImportedModel {
void requiredMacro(String name, TensorType type) { requiredMacros.put(name, type); }
/**
- * Returns all the output expressions of this indexed by name. The names consist of one or two parts
- * separated by dot, where the first part is the signature name
+ * Returns all the outputs of this by name. The names consist of one to three parts
+ * separated by dot, where the first part is the model name, the second is the signature name
* if signatures are used, or the expression name if signatures are not used and there are multiple
- * expressions, and the second is the output name if signature names are used.
+ * expressions, and the third is the output name if signature names are used.
*/
public List<Pair<String, RankingExpression>> outputExpressions() {
- List<Pair<String, RankingExpression>> expressions = new ArrayList<>();
+ List<Pair<String, RankingExpression>> names = new ArrayList<>();
for (Map.Entry<String, Signature> signatureEntry : signatures().entrySet()) {
for (Map.Entry<String, String> outputEntry : signatureEntry.getValue().outputs().entrySet())
- expressions.add(new Pair<>(signatureEntry.getKey() + "." + outputEntry.getKey(),
- expressions().get(outputEntry.getValue())));
+ names.add(new Pair<>(signatureEntry.getKey() + "." + outputEntry.getKey(),
+ expressions().get(outputEntry.getValue())));
if (signatureEntry.getValue().outputs().isEmpty()) // fallback: Signature without outputs
- expressions.add(new Pair<>(signatureEntry.getKey(),
- expressions().get(signatureEntry.getKey())));
+ names.add(new Pair<>(signatureEntry.getKey(),
+ expressions().get(signatureEntry.getKey())));
}
if (signatures().isEmpty()) { // fallback for models without signatures
if (expressions().size() == 1) {
- Map.Entry<String, RankingExpression> singleEntry = this.expressions.entrySet().iterator().next();
- expressions.add(new Pair<>(singleEntry.getKey(), singleEntry.getValue()));
+ Map.Entry<String, RankingExpression> singleEntry = expressions.entrySet().iterator().next();
+ names.add(new Pair<>(singleEntry.getKey(), singleEntry.getValue()));
}
else {
for (Map.Entry<String, RankingExpression> expressionEntry : expressions().entrySet()) {
- expressions.add(new Pair<>(expressionEntry.getKey(), expressionEntry.getValue()));
+ names.add(new Pair<>(expressionEntry.getKey(), expressionEntry.getValue()));
}
}
}
- return expressions;
+ return names;
}
/**
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java
index 32d33622a33..b1714b49256 100644
--- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java
+++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java
@@ -10,9 +10,7 @@ import java.util.Collection;
import java.util.Optional;
/**
- * All models imported from the models/ directory in the application package.
- * If this is empty it may be due to either not having any models in the application package,
- * or this being created for a ZooKeeper application package, which does not have imported models.
+ * All models imported from the models/ directory in the application package
*
* @author bratseth
*/
@@ -56,22 +54,16 @@ public class ImportedModels {
}
/**
- * Returns the model at the given location in the application package.
+ * Returns the model at the given location in the application package (lazily loaded),
*
- * @param modelPath the path to this model (file or directory, depending on model type)
- * under the application package, both from the root or relative to the
- * models directory works
- * @return the model at this path or null if none
+ * @param modelPath the full path to this model (file or directory, depending on model type)
+ * under the application package
+ * @throws IllegalArgumentException if the model cannot be loaded
*/
public ImportedModel get(File modelPath) {
- System.out.println("Name from " + modelPath + ": " + toName(modelPath));
return importedModels.get(toName(modelPath));
}
- public ImportedModel get(String modelName) {
- return importedModels.get(modelName);
- }
-
/** Returns an immutable collection of all the imported models */
public Collection<ImportedModel> all() {
return importedModels.values();