aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/numeric_matcher.h
blob: b5095128dd5ad9cfacfbbeedc974ed3122c44367 (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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/common/range.h>

namespace search { class QueryTermSimple; }

namespace search::attribute {

/*
 * Class used to determine if an attribute vector value is a match for
 * the query value.
 */
template<typename T>
class NumericMatcher
{
private:
    T _value;
    bool _valid;
protected:
    NumericMatcher(const QueryTermSimple& queryTerm, bool avoidUndefinedInRange);
    bool isValid() const { return _valid; }
    bool match(T v) const { return v == _value; }
    Int64Range getRange() const {
        return {static_cast<int64_t>(_value)};
    }
    DoubleRange getDoubleRange() const {
        return {static_cast<double>(_value)};
    }
};

}