blob: d05838e9b561b0ae7294931f653547672ff21ec3 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "querynodes.h"
#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vespa/searchlib/query/tree/templatetermvisitor.h>
namespace proton::matching {
/**
* Visits all terms of a node tree, and allocates MatchData space for
* each.
*/
class MatchDataReserveVisitor : public search::query::TemplateTermVisitor<MatchDataReserveVisitor, ProtonNodeTypes>
{
search::fef::MatchDataLayout &_mdl;
public:
template <class TermNode>
void visitTerm(TermNode &n) { n.allocateTerms(_mdl); }
void visit(ProtonNodeTypes::Equiv &n) override {
MatchDataReserveVisitor subAllocator(n.children_mdl);
for (size_t i = 0; i < n.getChildren().size(); ++i) {
n.getChildren()[i]->accept(subAllocator);
}
n.allocateTerms(_mdl);
}
MatchDataReserveVisitor(search::fef::MatchDataLayout &mdl) : _mdl(mdl) {}
};
}
|