blob: d63718387563723b1c4fe9e06b1126c9c7122c1e (
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
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "valuefeature.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stash.h>
using namespace search::fef;
namespace search::features {
ValueExecutor::ValueExecutor(const std::vector<feature_t> & values) :
FeatureExecutor(),
_values(values)
{
}
void
ValueExecutor::execute(uint32_t)
{
for (uint32_t i = 0; i < _values.size(); ++i) {
outputs().set_number(i, _values[i]);
}
}
void
SingleValueExecutor::execute(uint32_t)
{
outputs().set_number(0, _value);
}
void
SingleZeroValueExecutor::execute(uint32_t)
{
outputs().set_number(0, 0.0);
}
ValueBlueprint::ValueBlueprint() :
Blueprint("value"),
_values()
{
}
ValueBlueprint::~ValueBlueprint() = default;
void
ValueBlueprint::visitDumpFeatures(const IIndexEnvironment &, IDumpFeatureVisitor &) const
{
}
bool
ValueBlueprint::setup(const IIndexEnvironment &, const ParameterList & params)
{
for (uint32_t i = 0; i < params.size(); ++i) {
_values.push_back(params[i].asDouble());
vespalib::asciistream name;
name << i;
vespalib::asciistream desc;
desc << "value " << i;
describeOutput(name.str(), desc.str());
// we have no inputs
}
return true;
}
FeatureExecutor &
ValueBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &stash) const
{
if (_values.size() == 1) {
return stash.create<SingleValueExecutor>(_values[0]);
} else {
return stash.create<ValueExecutor>(_values);
}
}
}
|