diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2021-05-20 11:51:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 11:51:58 +0200 |
commit | eeb4067cc6ab6bbd0cc03b4a9ef9eaad27677cb1 (patch) | |
tree | 6a6517507428c7c166ef94a021f74b3c42a91bff /searchlib | |
parent | fa2ac899e0a34b6b6931c9c9ffc6298ef89d3eb3 (diff) | |
parent | ff423f32a08d29aea73a101b7b0094b35638d697 (diff) |
Merge pull request #17913 from vespa-engine/revert-17885-havardpe/external-ranking-expressions
Revert "external ranking expressions"
Diffstat (limited to 'searchlib')
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; }; |