blob: 40c83dac52214a645349d7c615b9a0f390343195 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "subqueries_feature.h"
#include "utils.h"
#include <vespa/vespalib/util/stash.h>
using namespace search::fef;
namespace search::features {
SubqueriesExecutor::SubqueriesExecutor(const IQueryEnvironment &env,
uint32_t fieldId)
: FeatureExecutor(),
_handles(),
_md(nullptr)
{
for (uint32_t i = 0; i < env.getNumTerms(); ++i) {
TermFieldHandle handle = util::getTermFieldHandle(env, i, fieldId);
if (handle != IllegalHandle) {
_handles.push_back(handle);
}
}
}
void SubqueriesExecutor::execute(uint32_t docId) {
uint32_t lsb = 0;
uint32_t msb = 0;
for (uint32_t i = 0; i < _handles.size(); ++i) {
const TermFieldMatchData *tfmd = _md->resolveTermField(_handles[i]);
if (tfmd->getDocId() == docId) {
lsb |= static_cast<uint32_t>(tfmd->getSubqueries());
msb |= tfmd->getSubqueries() >> 32;
}
}
outputs().set_number(0, lsb);
outputs().set_number(1, msb);
}
void
SubqueriesExecutor::handle_bind_match_data(const fef::MatchData &md)
{
_md = &md;
}
//-----------------------------------------------------------------------------
SubqueriesBlueprint::~SubqueriesBlueprint() = default;
bool SubqueriesBlueprint::setup(const IIndexEnvironment &,
const ParameterList ¶ms) {
_field = params[0].asField();
describeOutput("lsb", "32 least significant bits of the subquery bitmap"
" for the given field");
describeOutput("msb", "32 most significant bits of the subquery bitmap"
" for the given field");
return true;
}
FeatureExecutor &
SubqueriesBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash &stash) const {
return stash.create<SubqueriesExecutor>(queryEnv, _field->id());
}
}
|