aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/queryeval/booleanmatchiteratorwrapper.cpp
blob: 8061160cb5e418dff6a7a6d2dfd2bfe13f818d0d (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "booleanmatchiteratorwrapper.h"
#include <vespa/searchlib/fef/termfieldmatchdata.h>
#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
#include <vespa/vespalib/objects/visit.hpp>

namespace search::queryeval {

void
BooleanMatchIteratorWrapper::doSeek(uint32_t docid)
{
    _search->seek(docid);          // use outer seek for most robustness
    setDocId(_search->getDocId()); // propagate current iterator docid
}

void
BooleanMatchIteratorWrapper::doUnpack(uint32_t docid)
{
    if (_tfmdp != 0) {           // handle not having a match data (unranked, or multiple fields)
        _tfmdp->reset(docid);    // unpack ensures that docid is a hit
    }
}

BooleanMatchIteratorWrapper::BooleanMatchIteratorWrapper(
        SearchIterator::UP search,
        const fef::TermFieldMatchDataArray &matchData)
    : _search(std::move(search)),
      _tfmdp(0)
{
    if (matchData.size() == 1) {
        _tfmdp = matchData[0];
    }
}

void
BooleanMatchIteratorWrapper::visitMembers(vespalib::ObjectVisitor &visitor) const
{
    visit(visitor, "search", _search);
    // _match not visited
}

}