diff options
Diffstat (limited to 'searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp')
-rw-r--r-- | searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp index bd7c3a4e8fd..f6c10f7ddb5 100644 --- a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp +++ b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp @@ -4,7 +4,6 @@ #include <vespa/eval/eval/value_cache/constant_value.h> #include <vespa/searchcore/proton/matching/indexenvironment.h> #include <vespa/searchcore/proton/matching/ranking_expressions.h> -#include <vespa/searchcore/proton/matching/onnx_models.h> using namespace proton::matching; using search::fef::FieldInfo; @@ -34,34 +33,17 @@ RankingExpressions make_expressions() { OnnxModels make_models() { OnnxModels::Vector list; - list.emplace_back(std::move(OnnxModel("model1", "path1").input_feature("input1","feature1").output_name("output1", "out1"))); + list.emplace_back(OnnxModel("model1", "path1").input_feature("input1","feature1").output_name("output1", "out1")); list.emplace_back(OnnxModel("model2", "path2")); - return {std::move(list)}; + return OnnxModels(list); } -struct MyRankingAssetsRepo : public IRankingAssetsRepo { - RankingExpressions _expressions; - OnnxModels _onnxModels; - MyRankingAssetsRepo(RankingExpressions expressions, OnnxModels onnxModels) - : _expressions(std::move(expressions)), - _onnxModels(std::move(onnxModels)) - {} - ~MyRankingAssetsRepo() override; - ConstantValue::UP getConstant(const vespalib::string &) const override { - return {}; - } - - vespalib::string getExpression(const vespalib::string & name) const override { - return _expressions.loadExpression(name); - } - - const OnnxModel *getOnnxModel(const vespalib::string & name) const override { - return _onnxModels.getModel(name); +struct MyConstantValueRepo : public IConstantValueRepo { + virtual ConstantValue::UP getConstant(const vespalib::string &) const override { + return ConstantValue::UP(); } }; -MyRankingAssetsRepo::~MyRankingAssetsRepo() = default; - Schema::UP buildSchema() { @@ -78,19 +60,19 @@ buildEmptySchema() } struct Fixture { - MyRankingAssetsRepo repo; + MyConstantValueRepo repo; Schema::UP schema; IndexEnvironment env; - explicit Fixture(Schema::UP schema_) - : repo(make_expressions(), make_models()), + Fixture(Schema::UP schema_) + : repo(), schema(std::move(schema_)), - env(7, *schema, Properties(), repo) + env(7, *schema, Properties(), repo, make_expressions(), make_models()) { } const FieldInfo *assertField(size_t idx, const vespalib::string &name, DataType dataType, - CollectionType collectionType) const { + CollectionType collectionType) { const FieldInfo *field = env.getField(idx); ASSERT_TRUE(field != nullptr); EXPECT_EQUAL(field, env.getFieldByName(name)); @@ -103,7 +85,7 @@ struct Fixture { void assertHiddenAttributeField(size_t idx, const vespalib::string &name, DataType dataType, - CollectionType collectionType) const { + CollectionType collectionType) { const FieldInfo *field = assertField(idx, name, dataType, collectionType); EXPECT_FALSE(field->hasAttribute()); EXPECT_TRUE(field->type() == FieldType::HIDDEN_ATTRIBUTE); @@ -112,7 +94,7 @@ struct Fixture { void assertAttributeField(size_t idx, const vespalib::string &name, DataType dataType, - CollectionType collectionType) const { + CollectionType collectionType) { const FieldInfo *field = assertField(idx, name, dataType, collectionType); EXPECT_TRUE(field->hasAttribute()); EXPECT_TRUE(field->type() == FieldType::ATTRIBUTE); |