blob: bd209c361f97c43eb4c082082418ce81a1fbf955 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "chain.h"
#include <vespa/vespalib/util/stash.h>
#include <sstream>
namespace search::fef::test {
ChainExecutor::ChainExecutor() :
FeatureExecutor()
{
}
void
ChainExecutor::execute(uint32_t)
{
outputs().set_number(0, inputs().get_number(0));
}
ChainBlueprint::ChainBlueprint() :
Blueprint("chain")
{
}
bool
ChainBlueprint::setup(const IIndexEnvironment & indexEnv, const StringVector & params)
{
(void) indexEnv;
if (params.size() != 3) { // [type, children, value]
return false;
}
const std::string & type = params[0];
const std::string & children = params[1];
const std::string & value = params[2];
uint32_t numChildren;
std::istringstream iss(children);
iss >> std::dec >> numChildren;
std::ostringstream oss;
if (numChildren == 0) {
return false;
}
if (numChildren == 1) {
if (type == "basic") {
oss << "value(" << value << ")"; // value = input to value executor
defineInput(oss.str());
} else if (type == "cycle") {
oss << "chain(" << type << "," << value << "," << value << ")"; // value = where to insert the cycle
defineInput(oss.str());
} else {
return false;
}
} else {
oss << "chain(" << type << "," << (numChildren - 1) << "," << value << ")";
defineInput(oss.str());
}
describeOutput("out", "chain");
return true;
}
FeatureExecutor &
ChainBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash &stash) const
{
(void) queryEnv;
return stash.create<ChainExecutor>();
}
}
|