summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java
blob: 132597ee75e07239ad04b7acec71a45ab6203dd4 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.expressiontransforms;

import com.google.common.collect.ImmutableList;
import com.yahoo.searchlib.rankingexpression.RankingExpression;
import com.yahoo.searchlib.rankingexpression.transform.ConstantDereferencer;
import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
import com.yahoo.searchlib.rankingexpression.transform.Simplifier;
import com.yahoo.searchlib.rankingexpression.transform.TensorMaxMinTransformer;

import java.util.List;

/**
 * The transformations done on ranking expressions done at config time before passing them on to the Vespa
 * engine for execution.
 *
 * An instance of this class has scope of a compilation of a single rank profile.
 *
 * @author bratseth
 */
public class ExpressionTransforms {

    private final List<ExpressionTransformer> transforms;

    public ExpressionTransforms() {
        transforms =
                ImmutableList.of(new TensorFlowFeatureConverter(),
                                 new OnnxFeatureConverter(),
                                 new OnnxModelTransformer(),
                                 new XgboostFeatureConverter(),
                                 new LightGBMFeatureConverter(),
                                 new TokenTransformer(),
                                 new ConstantDereferencer(),
                                 new ConstantTensorTransformer(),
                                 new FunctionInliner(),
                                 new FunctionShadower(),
                                 new TensorMaxMinTransformer(),
                                 new Simplifier(),
                                 new BooleanExpressionTransformer());
    }

    public RankingExpression transform(RankingExpression expression, RankProfileTransformContext context) {
        for (ExpressionTransformer transformer : transforms)
            expression = transformer.transform(expression, context);
        return expression;
    }

}