aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/queryeval/scores.h
blob: 19976a2831b27c850a4b707d765a9b065f12efa5 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/common/feature.h>
#include <algorithm>

namespace search::queryeval {

struct Scores {
    feature_t low;
    feature_t high;
    Scores() : low(1), high(0) {}
    Scores(feature_t l, feature_t h) : low(l), high(h) {}

    bool isValid() const { return low <= high; }

    void update(feature_t score) {
        if (isValid()) {
            low = std::min(low, score);
            high = std::max(high, score);
        } else {
            low = score;
            high = score;
        }
    }
};

}