aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/search_context.h
blob: 1b17a27b6db6297572d8c8689628088c9806fbec (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
67
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/attribute/i_search_context.h>

namespace search {

class AttributeVector;
class QueryTermSimple;

}

namespace search::queryeval { class SearchIterator; }

namespace search::attribute {

class IPostingListSearchContext;

/*
 * SearchContext handles the creation of search iterators for a query term on an attribute vector.
 * This is an abstract class.
 */
class SearchContext : public ISearchContext
{
protected:
    using QueryTermSimpleUP = std::unique_ptr<QueryTermSimple>;
public:
    SearchContext(const SearchContext&) = delete;
    SearchContext(SearchContext&&) noexcept = default;
    SearchContext& operator=(const SearchContext&) = delete;
    SearchContext& operator=(SearchContext&&) noexcept = delete;
    ~SearchContext() override = default;

    HitEstimate calc_hit_estimate() const override;
    std::unique_ptr<queryeval::SearchIterator> createIterator(fef::TermFieldMatchData* matchData, bool strict) override;
    void fetchPostings(const queryeval::ExecuteInfo& execInfo, bool strict) override;
    bool valid() const override { return false; }
    Int64Range getAsIntegerTerm() const override { return Int64Range(); }
    DoubleRange getAsDoubleTerm() const override { return DoubleRange(); }

    const QueryTermUCS4* queryTerm() const override {
        return static_cast<const QueryTermUCS4*>(nullptr);
    }
    const vespalib::string& attributeName() const override;

    const AttributeVector& attribute() const { return _attr; }

protected:
    SearchContext(const AttributeVector& attr) noexcept
        : _attr(attr),
          _plsc(nullptr)
    {}

    const AttributeVector&                _attr;
    attribute::IPostingListSearchContext* _plsc;

    /**
     * Creates an attribute search iterator associated with this
     * search context. Postings lists are not used.
     **/
    virtual std::unique_ptr<queryeval::SearchIterator> createFilterIterator(fef::TermFieldMatchData* matchData, bool strict);

    bool getIsFilter() const;
};

}