blob: b70f5145e56875b7a11690e7fcc4fef99b718e2a (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.schema;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.tensor.TensorType;
import java.util.ArrayList;
import java.util.List;
/**
* Translation between schema info configuration and schema objects.
*
* @author bratseth
*/
class SchemaInfoConfigurer {
static List<Schema> toSchemas(SchemaInfoConfig schemaInfoConfig) {
return schemaInfoConfig.schema().stream().map(SchemaInfoConfigurer::toSchema).toList();
}
static Schema toSchema(SchemaInfoConfig.Schema schemaInfoConfig) {
Schema.Builder builder = new Schema.Builder(schemaInfoConfig.name());
for (var profileConfig : schemaInfoConfig.rankprofile()) {
RankProfile.Builder profileBuilder = new RankProfile.Builder(profileConfig.name());
profileBuilder.setHasSummaryFeatures(profileConfig.hasSummaryFeatures());
profileBuilder.setHasRankFeatures(profileConfig.hasRankFeatures());
for (var inputConfig : profileConfig.input())
profileBuilder.addInput(inputConfig.name(), TensorType.fromSpec(inputConfig.type()));
builder.add(profileBuilder.build());
}
for (var summaryConfig : schemaInfoConfig.summaryclass()) {
DocumentSummary.Builder summaryBuilder = new DocumentSummary.Builder(summaryConfig.name());
for (var field : summaryConfig.fields()) {
if (field.dynamic())
summaryBuilder.setDynamic(true);
summaryBuilder.add(new DocumentSummary.Field(field.name(), field.type()));
}
builder.add(summaryBuilder.build());
}
return builder.build();
}
static List<Cluster> toClusters(QrSearchersConfig config) {
List<Cluster> clusters = new ArrayList<>();
for (var searchCluster : config.searchcluster()) {
String clusterName = searchCluster.name();
var clusterInfo = new Cluster.Builder(clusterName);
clusterInfo.setStreaming(searchCluster.indexingmode() == QrSearchersConfig.Searchcluster.Indexingmode.Enum.STREAMING);
for (var schemaDef : searchCluster.searchdef())
clusterInfo.addSchema(schemaDef);
clusters.add(clusterInfo.build());
}
return clusters;
}
}
|