blob: c1b8b940245b91c5b3df6405e615db412239a008 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "staticrank.h"
#include <vespa/searchcommon/attribute/attributecontent.h>
namespace search {
namespace fef {
namespace test {
StaticRankExecutor::StaticRankExecutor(const search::attribute::IAttributeVector * attribute) :
FeatureExecutor(),
_attribute(attribute)
{
}
void
StaticRankExecutor::execute(uint32_t docId)
{
search::attribute::FloatContent staticRank;
if (_attribute != NULL) {
staticRank.allocate(_attribute->getMaxValueCount());
staticRank.fill(*_attribute, docId);
}
outputs().set_number(0, static_cast<feature_t>(staticRank[0]));
}
StaticRankBlueprint::StaticRankBlueprint() :
Blueprint("staticrank"),
_attributeName()
{
}
StaticRankBlueprint::~StaticRankBlueprint()
{
}
bool
StaticRankBlueprint::setup(const IIndexEnvironment & indexEnv, const StringVector & params)
{
(void) indexEnv;
if (params.size() != 1) {
return false;
}
_attributeName = params[0];
describeOutput("out", "static rank");
return true;
}
FeatureExecutor &
StaticRankBlueprint::createExecutor(const IQueryEnvironment & queryEnv, vespalib::Stash &stash) const
{
const search::attribute::IAttributeVector * av = queryEnv.getAttributeContext().getAttribute(_attributeName);
return stash.create<StaticRankExecutor>(av);
}
} // namespace test
} // namespace fef
} // namespace search
|