summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-05-20 11:42:43 +0200
committerGitHub <noreply@github.com>2021-05-20 11:42:43 +0200
commitff423f32a08d29aea73a101b7b0094b35638d697 (patch)
treed7cfe9762710cb102d28836db4ea257546257226 /searchlib
parentad936521af553e0278d9ceb3c47b328383f34806 (diff)
Revert "external ranking expressions"
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp29
-rw-r--r--searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/fef/iindexenvironment.h5
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironment.h5
5 files changed, 7 insertions, 53 deletions
diff --git a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp
index 6baa6581edf..251040ecfa7 100644
--- a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp
+++ b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp
@@ -67,38 +67,28 @@ struct SetupResult {
RankingExpressionBlueprint rank;
DummyDependencyHandler deps;
bool setup_ok;
- SetupResult(const TypeMap &object_inputs, const vespalib::string &expression,
- bool external_expression = false);
+ SetupResult(const TypeMap &object_inputs, const vespalib::string &expression);
~SetupResult();
};
SetupResult::SetupResult(const TypeMap &object_inputs,
- const vespalib::string &expression,
- bool external_expression)
+ const vespalib::string &expression)
: 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);
for (const auto &input: object_inputs) {
deps.define_object_input(input.first, ValueType::from_spec(input.second));
}
- std::vector<vespalib::string> params;
- if (external_expression) {
- params.push_back("my_expr");
- index_env.addRankingExpression("my_expr", expression);
- } else {
- index_env.getProperties().add("self.rankingScript", expression);
- }
- Blueprint &bp = rank;
- setup_ok = bp.setup(index_env, params);
+ setup_ok = rank.setup(index_env, {});
EXPECT_TRUE(!deps.accept_type_mismatch);
}
SetupResult::~SetupResult() = default;
void verify_output_type(const TypeMap &object_inputs,
- const vespalib::string &expression, const FeatureType &expect,
- bool external_expression = false)
+ const vespalib::string &expression, const FeatureType &expect)
{
- SetupResult result(object_inputs, expression, external_expression);
+ SetupResult result(object_inputs, expression);
EXPECT_TRUE(result.setup_ok);
EXPECT_EQUAL(1u, result.deps.output.size());
ASSERT_EQUAL(1u, result.deps.output_type.size());
@@ -136,13 +126,6 @@ TEST("require that ranking expression can resolve to concrete complex type") {
FeatureType::object(ValueType::from_spec("tensor(x{},y{},z{})"))));
}
-TEST("require that ranking expression can be external") {
- TEST_DO(verify_output_type({}, "a*b", FeatureType::number(), true));
- TEST_DO(verify_output_type({{"b", "double"}}, "a*b", FeatureType::object(ValueType::double_type()), true));
- TEST_DO(verify_output_type({{"a", "tensor(x{},y{})"}, {"b", "tensor(y{},z{})"}}, "a*b",
- FeatureType::object(ValueType::from_spec("tensor(x{},y{},z{})")), true));
-}
-
TEST("require that setup fails for incompatible types") {
TEST_DO(verify_setup_fail({{"a", "tensor(x{},y{})"}, {"b", "tensor(y[10],z{})"}}, "a*b"));
}
diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
index 070d70997e6..8cba6013627 100644
--- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
@@ -250,10 +250,7 @@ RankingExpressionBlueprint::setup(const fef::IIndexEnvironment &env,
}
//LOG(debug, "Script from config: '%s'\n", script.c_str());
} else if (params.size() == 1) {
- script = env.getRankingExpression(params[0].getValue());
- if (script.empty()) {
- script = params[0].getValue();
- }
+ script = params[0].getValue();
//LOG(debug, "Script from param: '%s'\n", script.c_str());
} else {
return fail("No expression given.");
diff --git a/searchlib/src/vespa/searchlib/fef/iindexenvironment.h b/searchlib/src/vespa/searchlib/fef/iindexenvironment.h
index a01d7d8762b..0cd017d8ffa 100644
--- a/searchlib/src/vespa/searchlib/fef/iindexenvironment.h
+++ b/searchlib/src/vespa/searchlib/fef/iindexenvironment.h
@@ -123,11 +123,6 @@ public:
virtual std::unique_ptr<vespalib::eval::ConstantValue> getConstantValue(const vespalib::string &name) const = 0;
/**
- * Returns the ranking expression with the given name or empty string if not found.
- **/
- virtual vespalib::string getRankingExpression(const vespalib::string &name) const = 0;
-
- /**
* Get configuration for the given onnx model.
**/
virtual const OnnxModel *getOnnxModel(const vespalib::string &name) const = 0;
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
index 85b20710f7a..d2d336dcdc8 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
@@ -54,22 +54,6 @@ IndexEnvironment::addConstantValue(const vespalib::string &name,
(void) insertRes;
}
-vespalib::string
-IndexEnvironment::getRankingExpression(const vespalib::string &name) const
-{
- auto pos = _expressions.find(name);
- if (pos != _expressions.end()) {
- return pos->second;
- }
- return {};
-}
-
-void
-IndexEnvironment::addRankingExpression(const vespalib::string &name, const vespalib::string &value)
-{
- _expressions.insert_or_assign(name, value);
-}
-
const OnnxModel *
IndexEnvironment::getOnnxModel(const vespalib::string &name) const
{
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
index ca63117971a..0d8d0091921 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
@@ -48,7 +48,6 @@ public:
};
using ConstantsMap = std::map<vespalib::string, Constant>;
- using ExprMap = std::map<vespalib::string, vespalib::string>;
using ModelMap = std::map<vespalib::string, OnnxModel>;
IndexEnvironment();
@@ -86,9 +85,6 @@ public:
vespalib::eval::ValueType type,
std::unique_ptr<vespalib::eval::Value> value);
- vespalib::string getRankingExpression(const vespalib::string &name) const override;
- void addRankingExpression(const vespalib::string &name, const vespalib::string &value);
-
const OnnxModel *getOnnxModel(const vespalib::string &name) const override;
void addOnnxModel(const OnnxModel &model);
@@ -102,7 +98,6 @@ private:
AttributeMap _attrMap;
TableManager _tableMan;
ConstantsMap _constants;
- ExprMap _expressions;
ModelMap _models;
};