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

#pragma once

#include "blueprint.h"
#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vector>

namespace search::fef { class TermFieldMatchData; }

namespace search::queryeval {

class WeightedSetTermBlueprint : public ComplexLeafBlueprint
{
    fef::MatchDataLayout       _layout;
    FieldSpec                  _children_field;
    std::vector<int32_t>       _weights;
    std::vector<Blueprint::UP> _terms;

public:
    explicit WeightedSetTermBlueprint(const FieldSpec &field);
    WeightedSetTermBlueprint(const WeightedSetTermBlueprint &) = delete;
    WeightedSetTermBlueprint &operator=(const WeightedSetTermBlueprint &) = delete;
    ~WeightedSetTermBlueprint() override;

    // used by create visitor
    // matches signature in dot product blueprint for common blueprint
    // building code. Hands out the same field spec to all children.
    FieldSpecBase getNextChildField(FieldSpecBase) { return _children_field; }

    // used by create visitor
    void reserve(size_t num_children);
    void addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate);
    void complete(HitEstimate estimate) {
        setEstimate(estimate);
    }

    void sort(InFlow in_flow) override;
    FlowStats calculate_flow_stats(uint32_t docid_limit) const override;

    SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda) const override;
    SearchIteratorUP createFilterSearch(FilterConstraint constraint) const override;
    std::unique_ptr<MatchingElementsSearch> create_matching_elements_search(const MatchingElementsFields &fields) const override;
    void visitMembers(vespalib::ObjectVisitor &visitor) const override;
private:
    void fetchPostings(const ExecuteInfo &execInfo) override;
};

}