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

#pragma once

#include "searchiterator.h"
#include "simpleresult.h"

namespace search::queryeval {

/**
 * Simple search class used to return a predefined set of
 * results. This class will mostly be used for testing.
 **/
class SimpleSearch : public SearchIterator
{
private:
    vespalib::string _tag;
    SimpleResult     _result;
    uint32_t         _index;
    bool             _strict;

    SimpleSearch(const SimpleSearch &);
    SimpleSearch &operator=(const SimpleSearch &);

protected:
    void doSeek(uint32_t docid) override;
    void doUnpack(uint32_t docid) override;

public:
    SimpleSearch(const SimpleResult &result, bool strict = true);
    SimpleSearch &tag(const vespalib::string &t) {
        _tag = t;
        return *this;
    }
    Trinary is_strict() const override { return _strict ? Trinary::True : Trinary::False; }
    void initRange(uint32_t begin_id, uint32_t end_id) override;
    void visitMembers(vespalib::ObjectVisitor &visitor) const override;
    ~SimpleSearch();
};

}