blob: b7b3020392fce35483e067dc7774161b4cb45796 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.ranking;
import com.yahoo.api.annotations.Beta;
import com.yahoo.component.annotation.Inject;
import com.yahoo.component.provider.ComponentRegistry;
/**
* factory for model-evaluation proxies
* @author arnej
*/
@Beta
public class RankingExpressionEvaluatorFactory {
private final ComponentRegistry<RankProfilesEvaluator> registry;
@Inject
public RankingExpressionEvaluatorFactory(ComponentRegistry<RankProfilesEvaluator> registry) {
this.registry = registry;
}
public RankProfilesEvaluator proxyForSchema(String schemaName) {
var component = registry.getComponent("ranking-expression-evaluator." + schemaName);
if (component == null) {
throw new IllegalArgumentException("ranking expression evaluator for schema '" + schemaName + "' not found");
}
return component;
}
public String toString() {
var buf = new StringBuilder();
buf.append(this.getClass().getName()).append(" containing: [");
for (var id : registry.allComponentsById().keySet()) {
buf.append(" ").append(id.toString());
}
buf.append(" ]");
return buf.toString();
}
}
|