aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/numeric_range_matcher.hpp
blob: 1517d5bf91ba055135a011ba43305312ec5b025d (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "numeric_range_matcher.h"
#include <vespa/searchlib/query/query_term_simple.h>

namespace search::attribute {

template<typename T>
NumericRangeMatcher<T>::NumericRangeMatcher(const QueryTermSimple& queryTerm, bool avoidUndefinedInRange)
    : _low(0),
      _high(0),
      _valid(false)
{
    QueryTermSimple::RangeResult<T> res = queryTerm.getRange<T>();
    _valid = res.isEqual() ? (res.valid && !res.adjusted) : res.valid;
    _low = res.low;
    _high = res.high;
    _limit = queryTerm.getRangeLimit();
    _max_per_group = queryTerm.getMaxPerGroup();
    if (_valid && avoidUndefinedInRange &&
        _low == std::numeric_limits<T>::min()) {
        _low += 1;
    }
}

}