summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ExpressionTransforms.java
blob: 34721ee4da1f1456b57b16d562d4d5fdcbc21ae6 (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
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.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 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 one complete deployment.
 *
 * @author bratseth
 */
public class ExpressionTransforms {

    private final List<ExpressionTransformer> transforms =
            ImmutableList.of(new TensorFlowFeatureConverter(),
                             new OnnxFeatureConverter(),
                             new XgboostFeatureConverter(),
                             new ConstantDereferencer(),
                             new ConstantTensorTransformer(),
                             new MacroInliner(),
                             new MacroShadower(),
                             new TensorTransformer(),
                             new Simplifier());

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

}