aboutsummaryrefslogtreecommitdiffstats
path: root/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
blob: 4be1f00dcbc1f0126f09669ab6cb2cf4de8d41b4 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/common/range.h>
#include <vespa/vespalib/stllike/string.h>

namespace search {

namespace fef {
    class TermFieldMatchData;
}
namespace queryeval {
    class SearchIterator;
}

class QueryTermBase;

namespace attribute {

class ISearchContext {
public:
    using UP = std::unique_ptr<ISearchContext>;
    using DocId = uint32_t;

private:
    virtual bool onCmp(DocId docId, int32_t &weight) const = 0;
    virtual bool onCmp(DocId docId) const = 0;

public:
    virtual ~ISearchContext() {}

    virtual unsigned int approximateHits() const = 0;

    /**
     * Creates an attribute search iterator associated with this
     * search context.
     *
     * @return attribute search iterator
     *
     * @param matchData the attribute match data used when
     * unpacking data for a hit
     *
     * @param strict whether the iterator should be strict or not
     **/
    virtual std::unique_ptr<queryeval::SearchIterator>
    createIterator(fef::TermFieldMatchData *matchData, bool strict) = 0;

    /*
     * Create temporary posting lists.
     * Should be called before createIterator() is called.
     */
    virtual void fetchPostings(bool strict) = 0;

    virtual bool valid() const = 0;
    virtual Int64Range getAsIntegerTerm() const = 0;
    virtual const QueryTermBase &queryTerm() const = 0;
    virtual const vespalib::string &attributeName() const = 0;

    bool cmp(DocId docId, int32_t &weight) const { return onCmp(docId, weight); }
    bool cmp(DocId docId) const { return onCmp(docId); }

};

}
}