diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-02-03 12:51:48 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-02-03 12:51:48 +0100 |
commit | a2d46da96686f5fc99b881ef1d06ccd54ab9867c (patch) | |
tree | 38d78a683eaf6b385e5bba6dec9e29f201f217ed /searchcore | |
parent | 97a9d25154b863baac946e11d95a8fa63d97a738 (diff) |
Drop ranking assets repo from SearchableDocSubDB.
Diffstat (limited to 'searchcore')
8 files changed, 45 insertions, 59 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index a7d57a1f1b1..db5fb1ae294 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -153,7 +153,6 @@ struct Fixture vespalib::TestClock _clock; matching::QueryLimiter _queryLimiter; EmptyConstantValueFactory _constantValueFactory; - RankingAssetsRepo _constantValueRepo; vespalib::ThreadStackExecutor _summaryExecutor; std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; SessionManager _sessionMgr; @@ -178,7 +177,6 @@ Fixture::Fixture() : _clock(), _queryLimiter(), _constantValueFactory(), - _constantValueRepo(_constantValueFactory), _summaryExecutor(8), _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), _sessionMgr(100), @@ -190,7 +188,7 @@ Fixture::Fixture() std::filesystem::create_directory(std::filesystem::path(BASE_DIR)); initViewSet(_views); _configurer = std::make_unique<Configurer>(_views._summaryMgr, _views.searchView, _views.feedView, _queryLimiter, - _constantValueRepo, _clock.clock(), "test", 0); + _constantValueFactory, _clock.clock(), "test", 0); } Fixture::~Fixture() = default; @@ -199,7 +197,8 @@ Fixture::initViewSet(ViewSet &views) { using IndexManager = proton::index::IndexManager; using IndexConfig = proton::index::IndexConfig; - auto matchers = std::make_shared<Matchers>(_clock.clock(), _queryLimiter, _constantValueRepo); + RankingAssetsRepo ranking_assets_repo_source(_constantValueFactory, {}, {}, {}); + auto matchers = std::make_shared<Matchers>(_clock.clock(), _queryLimiter, ranking_assets_repo_source); auto indexMgr = make_shared<IndexManager>(BASE_DIR, IndexConfig(searchcorespi::index::WarmupConfig(), 2, 0), Schema(), 1, views._reconfigurer, views._service.write(), _summaryExecutor, TuneFileIndexManager(), TuneFileAttributes(), views._fileHeaderContext); diff --git a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp index 3c157221e60..39b06906a91 100644 --- a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp +++ b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp @@ -39,18 +39,25 @@ public: } }; +namespace { + +std::shared_ptr<RankingConstants> make_ranking_constants() { + RankingConstants::Vector constants; + constants.emplace_back("foo", "double", "path_1"); + constants.emplace_back("bar", "double", "path_3"); + return std::make_shared<RankingConstants>(constants); +} + +} + struct Fixture { MyConstantValueFactory factory; RankingAssetsRepo repo; Fixture() - : factory(), repo(factory) + : factory(), repo(factory, make_ranking_constants(), {}, {}) { factory.add("path_1", "double", 3); factory.add("path_2", "double", 5); - RankingConstants::Vector constants; - constants.emplace_back("foo", "double", "path_1"); - constants.emplace_back("bar", "double", "path_3"); - repo.reconfigure(std::make_shared<RankingConstants>(constants),{}, {}); } }; @@ -69,16 +76,4 @@ TEST_F("require that non-existing constant value in factory returns bad constant EXPECT_TRUE(f.repo.getConstant("bar")->type().is_error()); } -TEST_F("require that reconfigure replaces existing constant values in repo", Fixture) -{ - RankingConstants::Vector constants; - constants.emplace_back("bar", "double", "path_3"); - constants.emplace_back("baz", "double", "path_2"); - f.repo.reconfigure(std::make_shared<RankingConstants>(constants), {}, {}); - f.factory.add("path_3", "double", 7); - EXPECT_TRUE(f.repo.getConstant("foo").get() == nullptr); - EXPECT_EQUAL(7, f.repo.getConstant("bar")->value().as_double()); - EXPECT_EQUAL(5, f.repo.getConstant("baz")->value().as_double()); -} - TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.cpp b/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.cpp index 783a34389d8..cfe7f836e42 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.cpp @@ -6,22 +6,19 @@ using vespalib::eval::ConstantValue; namespace proton::matching { -RankingAssetsRepo::RankingAssetsRepo(const ConstantValueFactory &factory) +RankingAssetsRepo::RankingAssetsRepo(const ConstantValueFactory &factory, + std::shared_ptr<const RankingConstants> constants, + std::shared_ptr<const RankingExpressions> expressions, + std::shared_ptr<const OnnxModels> models) : _factory(factory), - _constants() + _constants(std::move(constants)), + _rankingExpressions(std::move(expressions)), + _onnxModels(std::move(models)) { } RankingAssetsRepo::~RankingAssetsRepo() = default; -void -RankingAssetsRepo::reconfigure(RankingConstants::SP constants, RankingExpressions::SP expressions, OnnxModels::SP models) -{ - _constants = std::move(constants); - _rankingExpressions = std::move(expressions); - _onnxModels = std::move(models); -} - ConstantValue::UP RankingAssetsRepo::getConstant(const vespalib::string &name) const { diff --git a/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.h b/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.h index 37d814fc8d3..3e502d2ef69 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.h +++ b/searchcore/src/vespa/searchcore/proton/matching/ranking_assets_repo.h @@ -21,14 +21,16 @@ private: using ConstantValueFactory = vespalib::eval::ConstantValueFactory; const ConstantValueFactory &_factory; - std::shared_ptr<const RankingConstants> _constants; - std::shared_ptr<const RankingExpressions> _rankingExpressions; - std::shared_ptr<const OnnxModels> _onnxModels; + const std::shared_ptr<const RankingConstants> _constants; + const std::shared_ptr<const RankingExpressions> _rankingExpressions; + const std::shared_ptr<const OnnxModels> _onnxModels; public: - explicit RankingAssetsRepo(const ConstantValueFactory &factory); + RankingAssetsRepo(const ConstantValueFactory &factory, + std::shared_ptr<const RankingConstants> constants, + std::shared_ptr<const RankingExpressions> expressions, + std::shared_ptr<const OnnxModels> models); ~RankingAssetsRepo() override; - void reconfigure(RankingConstants::SP constants, RankingExpressions::SP expressions, OnnxModels::SP models); vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &name) const override; vespalib::string getExpression(const vespalib::string &name) const override; const search::fef::OnnxModel *getOnnxModel(const vespalib::string &name) const override; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index 68233419e74..f809f570e71 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -90,7 +90,7 @@ SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, SearchViewHolder &searchView, FeedViewHolder &feedView, matching::QueryLimiter &queryLimiter, - matching::RankingAssetsRepo &rankingAssetsRepo, + const vespalib::eval::ConstantValueFactory& constant_value_factory, const vespalib::Clock &clock, const vespalib::string &subDbName, uint32_t distributionKey) : @@ -98,7 +98,7 @@ SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, _searchView(searchView), _feedView(feedView), _queryLimiter(queryLimiter), - _rankingAssetsRepo(rankingAssetsRepo), + _constant_value_factory(constant_value_factory), _clock(clock), _subDbName(subDbName), _distributionKey(distributionKey) @@ -107,10 +107,15 @@ SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, SearchableDocSubDBConfigurer::~SearchableDocSubDBConfigurer() = default; std::shared_ptr<Matchers> -SearchableDocSubDBConfigurer::createMatchers(const Schema::SP &schema, - const RankProfilesConfig &cfg) +SearchableDocSubDBConfigurer::createMatchers(const DocumentDBConfig& new_config_snapshot) { - auto newMatchers = std::make_shared<Matchers>(_clock, _queryLimiter, _rankingAssetsRepo); + auto& schema = new_config_snapshot.getSchemaSP(); + auto& cfg = new_config_snapshot.getRankProfilesConfig(); + matching::RankingAssetsRepo ranking_assets_repo_source(_constant_value_factory, + new_config_snapshot.getRankingConstantsSP(), + new_config_snapshot.getRankingExpressionsSP(), + new_config_snapshot.getOnnxModelsSP()); + auto newMatchers = std::make_shared<Matchers>(_clock, _queryLimiter, ranking_assets_repo_source); auto& ranking_assets_repo = newMatchers->get_ranking_assets_repo(); for (const auto &profile : cfg.rankprofile) { vespalib::string name = profile.name; @@ -197,10 +202,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, SearchView::SP searchView = _searchView.get(); Matchers::SP matchers = searchView->getMatchers(); if (params.shouldMatchersChange()) { - _rankingAssetsRepo.reconfigure(newConfig.getRankingConstantsSP(), - newConfig.getRankingExpressionsSP(), - newConfig.getOnnxModelsSP()); - Matchers::SP newMatchers = createMatchers(newConfig.getSchemaSP(), newConfig.getRankProfilesConfig()); + Matchers::SP newMatchers = createMatchers(newConfig); matchers = newMatchers; shouldMatchViewChange = true; } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index b0f0694a929..0937a754640 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -10,7 +10,6 @@ #include <vespa/searchcore/proton/attribute/i_attribute_writer.h> #include <vespa/searchcore/proton/docsummary/summarymanager.h> #include <vespa/searchcore/proton/index/i_index_writer.h> -#include <vespa/searchcore/proton/matching/ranking_assets_repo.h> #include <vespa/searchcore/proton/reprocessing/i_reprocessing_initializer.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/searchcommon/common/schema.h> @@ -43,7 +42,7 @@ private: SearchViewHolder &_searchView; FeedViewHolder &_feedView; matching::QueryLimiter &_queryLimiter; - matching::RankingAssetsRepo &_rankingAssetsRepo; + const vespalib::eval::ConstantValueFactory& _constant_value_factory; const vespalib::Clock &_clock; vespalib::string _subDbName; uint32_t _distributionKey; @@ -69,14 +68,13 @@ public: SearchViewHolder &searchView, FeedViewHolder &feedView, matching::QueryLimiter &queryLimiter, - matching::RankingAssetsRepo &rankingAssetsRepo, + const vespalib::eval::ConstantValueFactory& constant_value_factory, const vespalib::Clock &clock, const vespalib::string &subDbName, uint32_t distributionKey); ~SearchableDocSubDBConfigurer(); - Matchers::SP createMatchers(const search::index::Schema::SP &schema, - const vespa::config::search::RankProfilesConfig &cfg); + Matchers::SP createMatchers(const DocumentDBConfig& new_config_snapshot); void reconfigureIndexSearchable(); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 449d0e8d357..3f79b02830d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -36,8 +36,7 @@ SearchableDocSubDB::SearchableDocSubDB(const Config &cfg, const Context &ctx) _rFeedView(), _tensorLoader(FastValueBuilderFactory::get()), _constantValueCache(_tensorLoader), - _rankingAssetsRepo(_constantValueCache), - _configurer(_iSummaryMgr, _rSearchView, _rFeedView, ctx._queryLimiter, _rankingAssetsRepo, ctx._clock, + _configurer(_iSummaryMgr, _rSearchView, _rFeedView, ctx._queryLimiter, _constantValueCache, ctx._clock, getSubDbName(), ctx._fastUpdCtx._storeOnlyCtx._owner.getDistributionKey()), _warmupExecutor(ctx._warmupExecutor), _realGidToLidChangeHandler(std::make_shared<GidToLidChangeHandler>()), @@ -197,12 +196,8 @@ SearchableDocSubDB::initViews(const DocumentDBConfig &configSnapshot) assert(_writeService.master().isCurrentThread()); AttributeManager::SP attrMgr = getAndResetInitAttributeManager(); - const Schema::SP &schema = configSnapshot.getSchemaSP(); const IIndexManager::SP &indexMgr = getIndexManager(); - _rankingAssetsRepo.reconfigure(configSnapshot.getRankingConstantsSP(), - configSnapshot.getRankingExpressionsSP(), - configSnapshot.getOnnxModelsSP()); - Matchers::SP matchers = _configurer.createMatchers(schema, configSnapshot.getRankProfilesConfig()); + Matchers::SP matchers = _configurer.createMatchers(configSnapshot); auto matchView = std::make_shared<MatchView>(std::move(matchers), indexMgr->getSearchable(), attrMgr, _owner.session_manager(), _metaStoreCtx, _docIdLimit); _rSearchView.set(SearchView::create( diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index e3906f84f13..63100f7e6a9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -16,7 +16,6 @@ #include <vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h> #include <vespa/searchcore/proton/index/i_index_writer.h> #include <vespa/searchcore/proton/index/indexmanager.h> -#include <vespa/searchcore/proton/matching/ranking_assets_repo.h> #include <vespa/searchcorespi/index/iindexmanager.h> #include <vespa/vespalib/util/blockingthreadstackexecutor.h> @@ -68,7 +67,6 @@ private: vespalib::VarHolder<SearchableFeedView::SP> _rFeedView; vespalib::eval::ConstantTensorLoader _tensorLoader; vespalib::eval::ConstantValueCache _constantValueCache; - matching::RankingAssetsRepo _rankingAssetsRepo; SearchableDocSubDBConfigurer _configurer; vespalib::Executor &_warmupExecutor; std::shared_ptr<GidToLidChangeHandler> _realGidToLidChangeHandler; |