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
68
69
70
71
72
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "wand_parts.h"
#include "weak_and_heap.h"
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
#include <memory>
#include <vector>
namespace search::queryeval {
const uint32_t DEFAULT_PARALLEL_WAND_SCORES_ADJUST_FREQUENCY = 4;
/**
* Blueprint for the parallel weak and search operator.
*/
class ParallelWeakAndBlueprint : public ComplexLeafBlueprint
{
private:
using score_t = wand::score_t;
mutable SharedWeakAndPriorityQueue _scores;
const wand::score_t _scoreThreshold;
double _thresholdBoostFactor;
const uint32_t _scoresAdjustFrequency;
fef::MatchDataLayout _layout;
std::vector<int32_t> _weights;
std::vector<Blueprint::UP> _terms;
public:
ParallelWeakAndBlueprint(const ParallelWeakAndBlueprint &) = delete;
ParallelWeakAndBlueprint &operator=(const ParallelWeakAndBlueprint &) = delete;
ParallelWeakAndBlueprint(FieldSpecBase field,
uint32_t scoresToTrack,
score_t scoreThreshold,
double thresholdBoostFactor);
ParallelWeakAndBlueprint(FieldSpecBase field,
uint32_t scoresToTrack,
score_t scoreThreshold,
double thresholdBoostFactor,
uint32_t scoresAdjustFrequency);
~ParallelWeakAndBlueprint() override;
const WeakAndHeap &getScores() const { return _scores; }
score_t getScoreThreshold() const { return _scoreThreshold; }
double getThresholdBoostFactor() const { return _thresholdBoostFactor; }
// Used by create visitor
FieldSpecBase getNextChildField(FieldSpecBase parent) {
return {parent.getFieldId(), _layout.allocTermField(parent.getFieldId()), false};
}
// 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);
set_tree_size(_terms.size() + 1);
}
SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override;
std::unique_ptr<SearchIterator> createFilterSearch(bool strict, FilterConstraint constraint) const override;
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
void fetchPostings(const ExecuteInfo &execInfo) override;
bool always_needs_unpack() const override;
};
}
|