aboutsummaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/vsm/searcher/intfieldsearcher.cpp
blob: 3984254274f1e2989c440a38cc2d42df8d613e76 (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
40
41
42
43
44
45
46
47
48
49
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "intfieldsearcher.h"

using search::streaming::QueryTerm;
using search::streaming::QueryTermList;

namespace vsm {

std::unique_ptr<FieldSearcher>
IntFieldSearcher::duplicate() const
{
    return std::make_unique<IntFieldSearcher>(*this);
}

IntFieldSearcher::IntFieldSearcher(FieldIdT fId) :
    FieldSearcher(fId),
    _intTerm()
{ }

IntFieldSearcher::~IntFieldSearcher() = default;

void IntFieldSearcher::prepare(search::streaming::QueryTermList& qtl,
                               const SharedSearcherBuf& buf,
                               const vsm::FieldPathMapT& field_paths,
                               search::fef::IQueryEnvironment& query_env)
{
    _intTerm.clear();
    FieldSearcher::prepare(qtl, buf, field_paths, query_env);
    for (auto qt : qtl) {
        size_t sz(qt->termLen());
        if (sz) {
            auto range = qt->getRange<int64_t>();
            _intTerm.emplace_back(range.low, range.high, range.valid);
        }
    }
}

void IntFieldSearcher::onValue(const document::FieldValue & fv)
{
    for(size_t j=0, jm(_intTerm.size()); j < jm; j++) {
        const IntInfo & ii = _intTerm[j];
        if (ii.valid() && (ii.cmp(fv.getAsLong()))) {
            addHit(*_qtl[j], 0);
        }
    }
    set_element_length(1);
}

}