test that appropriate executor is created
#include <vespa/searchlib/features/rankingexpressionfeature.h>
#include <vespa/searchlib/fef/test/dummy_dependency_handler.h>
#include <vespa/searchlib/fef/test/indexenvironment.h>
+#include <vespa/searchlib/fef/test/queryenvironment.h>
using namespace search::features;
using namespace search::features::rankingexpression;
@@ -16,12 +17,16 @@ using namespace vespalib::eval;
using TypeMap = std::map<vespalib::string,vespalib::string>;
+struct DummyExecutor : FeatureExecutor {
+ void execute(uint32_t) override {}
+};
+
struct DummyExpression : IntrinsicExpression {
FeatureType type;
DummyExpression(const FeatureType &type_in) : type(type_in) {}
FeatureType result_type() const override { return type; }
- FeatureExecutor &create_executor(const QueryEnv &, vespalib::Stash &) const override {
- abort();
+ FeatureExecutor &create_executor(const QueryEnv &, vespalib::Stash &stash) const override {
+ return stash.create<DummyExecutor>();
}
};
@@ -53,7 +58,9 @@ ExpressionReplacer::SP make_replacer() {
}
struct SetupResult {
+ vespalib::Stash stash;
IndexEnvironment index_env;
+ QueryEnvironment query_env;
RankingExpressionBlueprint rank;
DummyDependencyHandler deps;
bool setup_ok;
@@ -63,7 +70,7 @@ struct SetupResult {
SetupResult::SetupResult(const TypeMap &object_inputs,
const vespalib::string &expression)
- : index_env(), rank(make_replacer()), deps(rank), setup_ok(false)
+ : stash(), index_env(), query_env(&index_env), rank(make_replacer()), deps(rank), setup_ok(false)
{
rank.setName("self");
index_env.getProperties().add("self.rankingScript", expression);
@@ -147,4 +154,10 @@ TEST("require that replaced expressions override result type") {
FeatureType::number()));
}
+TEST_F("require that replaced expressions create the appropriate executor", SetupResult({}, "foo")) {
+ EXPECT_TRUE(f1.setup_ok);
+ FeatureExecutor &executor = f1.rank.createExecutor(f1.query_env, f1.stash);
+ EXPECT_TRUE(dynamic_cast<DummyExecutor*>(&executor) != nullptr);
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }
