aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/gbdt/ResponseNode.java
blob: b7a685001df6ff649301ef470a1c048b6b5a0e33 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.gbdt;

import org.w3c.dom.Node;

import java.util.Optional;

/**
 * @author Simon Thoresen Hult
 */
public class ResponseNode extends TreeNode {

    private final double value;

    public ResponseNode(double value, Optional<Integer> samples) {
        super(samples);
        this.value = value;
    }

    public double value() {
        return value;
    }

    @Override
    public String toRankingExpression() {
        return String.valueOf(value);
    }

    public static ResponseNode fromDom(Node node) {
        return new ResponseNode(Double.valueOf(XmlHelper.getAttributeText(node, "value")),
                                toInteger(XmlHelper.getOptionalAttributeText(node, "nSamples")));
    }
}