blob: 1cc33664e8c815e30b21786d70cff7081b920a0e (
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
41
42
43
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
import com.yahoo.vespa.model.AbstractService;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* ONNX models tied to a search definition.
*
* @author lesters
*/
public class OnnxModels {
private final Map<String, OnnxModel> models = new HashMap<>();
public void add(OnnxModel model) {
model.validate();
String name = model.getName();
models.put(name, model);
}
public OnnxModel get(String name) {
return models.get(name);
}
public boolean has(String name) {
return models.containsKey(name);
}
public Map<String, OnnxModel> asMap() {
return Collections.unmodifiableMap(models);
}
/** Initiate sending of these models to some services over file distribution */
public void sendTo(Collection<? extends AbstractService> services) {
models.values().forEach(model -> model.sendTo(services));
}
}
|