diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-02-08 15:04:59 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-02-08 15:04:59 +0100 |
commit | 0046c0fd92c1cb57c3dbe95aa7a044f73734e453 (patch) | |
tree | 3e3ccfbe98cb7ba30c1e566946f2ef61fafa9640 /searchcore | |
parent | b6a290f08603587e1325d92550714c82630506a2 (diff) |
Delay creation of AttributeCollectionSpec.
Diffstat (limited to 'searchcore')
13 files changed, 161 insertions, 124 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 60f6c02d45a..9639f2c591e 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -2,23 +2,33 @@ #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/config-summary.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/eval/eval/value_cache/constant_value.h> +#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/attribute/attributemanager.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> #include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> +#include <vespa/searchcore/proton/common/docid_limit.h> +#include <vespa/searchcore/proton/common/pendinglidtracker.h> #include <vespa/searchcore/proton/docsummary/summarymanager.h> +#include <vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h> #include <vespa/searchcore/proton/index/index_writer.h> #include <vespa/searchcore/proton/index/indexmanager.h> #include <vespa/searchcore/proton/matching/querylimiter.h> +#include <vespa/searchcore/proton/matching/ranking_assets_repo.h> #include <vespa/searchcore/proton/matching/sessionmanager.h> #include <vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h> +#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h> #include <vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.h> #include <vespa/searchcore/proton/server/document_subdb_reconfig.h> #include <vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h> #include <vespa/searchcore/proton/server/reconfig_params.h> #include <vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h> +#include <vespa/searchcore/proton/server/searchview.h> +#include <vespa/searchcore/proton/server/searchable_feed_view.h> #include <vespa/searchcore/proton/server/summaryadapter.h> #include <vespa/searchcore/proton/test/documentdb_config_builder.h> #include <vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h> @@ -27,6 +37,7 @@ #include <vespa/searchlib/attribute/interlock.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> +#include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/testclock.h> #include <vespa/vespalib/util/threadstackexecutor.h> @@ -79,8 +90,8 @@ createRepo() struct ViewPtrs { - SearchView::SP sv; - SearchableFeedView::SP fv; + std::shared_ptr<SearchView> sv; + std::shared_ptr<SearchableFeedView> fv; ~ViewPtrs(); }; @@ -91,7 +102,7 @@ struct ViewSet IndexManagerDummyReconfigurer _reconfigurer; DummyFileHeaderContext _fileHeaderContext; TransportAndExecutorService _service; - SearchableFeedView::SerialNum serialNum; + SerialNum serialNum; std::shared_ptr<const DocumentTypeRepo> repo; DocTypeName _docTypeName; DocIdLimit _docIdLimit; @@ -99,8 +110,8 @@ struct ViewSet ISummaryManager::SP _summaryMgr; proton::IDocumentMetaStoreContext::SP _dmsc; std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; - VarHolder<SearchView::SP> searchView; - VarHolder<SearchableFeedView::SP> feedView; + VarHolder<std::shared_ptr<SearchView>> searchView; + VarHolder<std::shared_ptr<SearchableFeedView>> feedView; HwInfo _hwInfo; ViewSet(); ~ViewSet(); @@ -169,9 +180,9 @@ struct Fixture SerialNum serial_num); IReprocessingInitializer::UP reconfigure(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, const ReconfigParams& reconfig_params, IDocumentDBReferenceResolver& resolver, + uint32_t docid_limit, SerialNum serial_num); }; @@ -247,8 +258,8 @@ Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, { EXPECT_FALSE(reconfig_params.shouldAttributeManagerChange()); uint32_t docid_limit = 1; - AttributeCollectionSpec attr_spec(AttributeCollectionSpec::AttributeList(), docid_limit, serial_num); - auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, std::move(attr_spec), reconfig_params, serial_num); + AttributeCollectionSpecFactory attr_spec_factory(AllocStrategy(), false); + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, attr_spec_factory, reconfig_params, docid_limit, serial_num); prepared_reconfig->complete(docid_limit, serial_num); _configurer->reconfigure(new_config_snapshot, old_config_snapshot, reconfig_params, resolver, *prepared_reconfig, serial_num); } @@ -256,13 +267,13 @@ Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, IReprocessingInitializer::UP Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, const ReconfigParams& reconfig_params, IDocumentDBReferenceResolver& resolver, + uint32_t docid_limit, SerialNum serial_num) { - auto docid_limit = attr_spec.getDocIdLimit(); - auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, std::move(attr_spec), reconfig_params, serial_num); + AttributeCollectionSpecFactory attr_spec_factory(AllocStrategy(), false); + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, attr_spec_factory, reconfig_params, docid_limit, serial_num); prepared_reconfig->complete(docid_limit, serial_num); return _configurer->reconfigure(new_config_snapshot, old_config_snapshot, reconfig_params, resolver, *prepared_reconfig, serial_num); } @@ -335,19 +346,19 @@ struct FastAccessFixture IReprocessingInitializer::UP reconfigure(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, + uint32_t docid_limit, SerialNum serial_num); }; IReprocessingInitializer::UP FastAccessFixture::reconfigure(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, + uint32_t docid_limit, SerialNum serial_num) { ReconfigParams reconfig_params{CCR()}; - auto docid_limit = attr_spec.getDocIdLimit(); - auto prepared_reconfig = _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, std::move(attr_spec), reconfig_params, serial_num); + AttributeCollectionSpecFactory attr_spec_factory(AllocStrategy(), true); + auto prepared_reconfig = _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, attr_spec_factory, reconfig_params, docid_limit, serial_num); prepared_reconfig->complete(docid_limit, serial_num); return _configurer.reconfigure(new_config_snapshot, old_config_snapshot, *prepared_reconfig, serial_num); } @@ -516,8 +527,7 @@ TEST_F("require that we can reconfigure attribute manager", Fixture) // Use new config snapshot == old config snapshot (only relevant for reprocessing) SerialNum reconfig_serial_num = 0; f.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, reconfig_serial_num), - params, f._resolver, reconfig_serial_num); + params, f._resolver, 1, reconfig_serial_num); ViewPtrs n = f._views.getViewPtrs(); { // verify search view @@ -555,8 +565,7 @@ checkAttributeWriterChangeOnRepoChange(Fixture &f, bool docTypeRepoChanged) // Use new config snapshot == old config snapshot (only relevant for reprocessing) SerialNum reconfig_serial_num = 0; f.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, reconfig_serial_num), - params, f._resolver, reconfig_serial_num); + params, f._resolver, 1, reconfig_serial_num); auto newAttributeWriter = getAttributeWriter(f); if (docTypeRepoChanged) { EXPECT_NOT_EQUAL(oldAttributeWriter, newAttributeWriter); @@ -577,8 +586,7 @@ TEST_F("require that reconfigure returns reprocessing initializer when changing SerialNum reconfig_serial_num = 0; IReprocessingInitializer::UP init = f.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, reconfig_serial_num), - params, f._resolver, reconfig_serial_num); + params, f._resolver, 1, reconfig_serial_num); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); @@ -589,8 +597,7 @@ TEST_F("require that we can reconfigure attribute writer", FastAccessFixture) { FastAccessFeedView::SP o = f._view._feedView.get(); SerialNum reconfig_serial_num = 0; - f.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, reconfig_serial_num), reconfig_serial_num); + f.reconfigure(*createConfig(), *createConfig(), 1, reconfig_serial_num); FastAccessFeedView::SP n = f._view._feedView.get(); FastAccessFeedViewComparer cmp(o, n); @@ -603,8 +610,7 @@ TEST_F("require that we can reconfigure attribute writer", FastAccessFixture) TEST_F("require that reconfigure returns reprocessing initializer", FastAccessFixture) { SerialNum reconfig_serial_num = 0; - IReprocessingInitializer::UP init = f.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, reconfig_serial_num), reconfig_serial_num); + auto init = f.reconfigure(*createConfig(), *createConfig(), 1, reconfig_serial_num); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp index 2be0e0a58f8..be43a5323bb 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "attribute_collection_spec_factory.h" +#include "attribute_collection_spec.h" #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchcommon/attribute/config.h> diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h index 06b3f677640..185daa15f2f 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h @@ -2,15 +2,17 @@ #pragma once -#include "attribute_collection_spec.h" #include <vespa/searchcore/proton/common/alloc_strategy.h> #include <vespa/searchlib/common/serialnum.h> +#include <memory> #include <optional> namespace vespa::config::search::internal { class InternalAttributesType; }; namespace proton { +class AttributeCollectionSpec; + /** * A factory for generating an AttributeCollectionSpec based on AttributesConfig * from the config server. diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h index cb9f6da436f..c924c1c5b20 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h @@ -2,10 +2,8 @@ #pragma once -#include "attribute_collection_spec.h" -#include "i_attribute_factory.h" #include "i_attribute_manager.h" -#include "i_attribute_initializer_registry.h" +#include "attribute_collection_spec.h" #include <set> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/stllike/hash_map.h> @@ -21,8 +19,13 @@ namespace vespalib { class ThreadExecutor; } namespace proton { +class AttributeCollectionSpec; class AttributeDiskLayout; +class AttributeInitializerResult; +class AttributeSpec; class FlushableAttribute; +struct IAttributeFactory; +struct IAttributeInitializerRegistry; class ShrinkLidSpaceFlushTarget; /** @@ -81,7 +84,7 @@ private: vespalib::string _documentSubDbName; const search::TuneFileAttributes _tuneFileAttributes; const search::common::FileHeaderContext &_fileHeaderContext; - IAttributeFactory::SP _factory; + std::shared_ptr<IAttributeFactory> _factory; std::shared_ptr<search::attribute::Interlock> _interlock; vespalib::ISequencedTaskExecutor &_attributeFieldWriter; vespalib::Executor& _shared_executor; @@ -114,7 +117,7 @@ public: std::shared_ptr<search::attribute::Interlock> interlock, vespalib::ISequencedTaskExecutor &attributeFieldWriter, vespalib::Executor& shared_executor, - IAttributeFactory::SP factory, + std::shared_ptr<IAttributeFactory> factory, const HwInfo &hwInfo); AttributeManager(const AttributeManager &currMgr, Spec && newSpec, @@ -165,7 +168,7 @@ public: void pruneRemovedFields(search::SerialNum serialNum) override; - const IAttributeFactory::SP &getFactory() const override { return _factory; } + const std::shared_ptr<IAttributeFactory> &getFactory() const override { return _factory; } vespalib::ISequencedTaskExecutor &getAttributeFieldWriter() const override; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h index 43f7eab8a6c..437e7bd0208 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h @@ -2,7 +2,6 @@ #pragma once -#include "attribute_collection_spec.h" #include "exclusive_attribute_read_accessor.h" #include "i_attribute_factory.h" #include <vespa/searchcommon/attribute/i_attribute_functor.h> @@ -21,6 +20,7 @@ namespace vespalib { namespace proton { +class AttributeCollectionSpec; class IAttributeManagerReconfig; class ImportedAttributesRepo; diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index ea968a60322..1ecd2ac488a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -101,14 +101,6 @@ FastAccessDocSubDB::setupAttributeManager(AttributeManager::SP attrMgrResult) } -std::unique_ptr<AttributeCollectionSpec> -FastAccessDocSubDB::createAttributeSpec(const AttributesConfig &attrCfg, const AllocStrategy& alloc_strategy, std::optional<SerialNum> serialNum) const -{ - uint32_t docIdLimit(_dms->getCommittedDocIdLimit()); - AttributeCollectionSpecFactory factory(alloc_strategy, _fastAccessAttributesOnly); - return factory.create(attrCfg, docIdLimit, serialNum); -} - void FastAccessDocSubDB::initFeedView(IAttributeWriter::SP writer, const DocumentDBConfig &configSnapshot) { @@ -246,8 +238,9 @@ std::unique_ptr<DocumentSubDBReconfig> FastAccessDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional<SerialNum> serial_num) { auto alloc_strategy = new_config_snapshot.get_alloc_config().make_alloc_strategy(_subDbType); - auto attr_spec = createAttributeSpec(new_config_snapshot.getAttributesConfig(), alloc_strategy, serial_num); - return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, std::move(*attr_spec), reconfig_params, serial_num); + AttributeCollectionSpecFactory attr_spec_factory(alloc_strategy, _fastAccessAttributesOnly); + auto docid_limit = _dms->getCommittedDocIdLimit(); + return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, attr_spec_factory, reconfig_params, docid_limit, serial_num); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index cc82f863e80..66ac20f5ebd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "fast_access_doc_subdb_configurer.h" #include "storeonlydocsubdb.h" +#include "fast_access_doc_subdb_configurer.h" #include <vespa/config-attributes.h> #include <vespa/searchcore/proton/attribute/attributemanager.h> #include <vespa/searchcore/proton/common/docid_limit.h> @@ -82,7 +82,7 @@ private: std::shared_ptr<AttributeManager::SP> attrMgrResult) const; void setupAttributeManager(AttributeManager::SP attrMgrResult); - void initFeedView(IAttributeWriter::SP writer, const DocumentDBConfig &configSnapshot); + void initFeedView(std::shared_ptr<IAttributeWriter> writer, const DocumentDBConfig &configSnapshot); protected: using Parent = StoreOnlyDocSubDB; @@ -92,7 +92,6 @@ protected: std::shared_ptr<search::attribute::Interlock> _attribute_interlock; DocIdLimit _docIdLimit; - std::unique_ptr<AttributeCollectionSpec> createAttributeSpec(const AttributesConfig &attrCfg, const AllocStrategy& alloc_strategy, std::optional<SerialNum> serialNum) const; AttributeManager::SP getAndResetInitAttributeManager(); virtual IFlushTargetList getFlushTargetsInternal() override; void reconfigureAttributeMetrics(const IAttributeManager &newMgr, const IAttributeManager &oldMgr); @@ -100,6 +99,8 @@ protected: IReprocessingTask::UP createReprocessingTask(IReprocessingInitializer &initializer, const std::shared_ptr<const document::DocumentTypeRepo> &docTypeRepo) const; + bool get_fast_access_attributes_only() const noexcept { return _fastAccessAttributesOnly; } + public: FastAccessDocSubDB(const Config &cfg, const Context &ctx); ~FastAccessDocSubDB(); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp index ad7ef2f0dc0..52e87ee7283 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp @@ -1,10 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "fast_access_doc_subdb_configurer.h" +#include "fast_access_feed_view.h" #include "document_subdb_reconfig.h" #include "documentdbconfig.h" #include "reconfig_params.h" #include <vespa/searchcore/proton/attribute/attributemanager.h> +#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h> #include <vespa/searchcore/proton/attribute/attribute_manager_reconfig.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/common/document_type_inspector.h> @@ -20,9 +22,9 @@ using ARIConfig = AttributeReprocessingInitializer::Config; void FastAccessDocSubDBConfigurer::reconfigureFeedView(FastAccessFeedView & curr, - Schema::SP schema, + std::shared_ptr<Schema> schema, std::shared_ptr<const DocumentTypeRepo> repo, - IAttributeWriter::SP writer) + std::shared_ptr<IAttributeWriter> writer) { _feedView.set(std::make_shared<FastAccessFeedView>( StoreOnlyFeedView::Context(curr.getSummaryAdapter(), @@ -48,8 +50,9 @@ FastAccessDocSubDBConfigurer::~FastAccessDocSubDBConfigurer() = default; std::unique_ptr<DocumentSubDBReconfig> FastAccessDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec && attr_spec, + const AttributeCollectionSpecFactory& attr_spec_factory, const ReconfigParams& reconfig_params, + uint32_t docid_limit, std::optional<search::SerialNum> serial_num) { (void) new_config_snapshot; @@ -59,7 +62,8 @@ FastAccessDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_confi auto old_attribute_manager = old_attribute_writer->getAttributeManager(); auto reconfig = std::make_unique<DocumentSubDBReconfig>(std::shared_ptr<Matchers>(), old_attribute_manager); if (reconfig_params.shouldAttributeManagerChange()) { - reconfig->set_attribute_manager_reconfig(old_attribute_manager->prepare_create(std::move(attr_spec))); + auto attr_spec = attr_spec_factory.create(new_config_snapshot.getAttributesConfig(), docid_limit, serial_num); + reconfig->set_attribute_manager_reconfig(old_attribute_manager->prepare_create(std::move(*attr_spec))); } return reconfig; } @@ -70,7 +74,7 @@ FastAccessDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, const DocumentSubDBReconfig& prepared_reconfig, search::SerialNum serial_num) { - FastAccessFeedView::SP oldView = _feedView.get(); + std::shared_ptr<FastAccessFeedView> oldView = _feedView.get(); auto writer = std::make_shared<AttributeWriter>(prepared_reconfig.attribute_manager()); reconfigureFeedView(*oldView, newConfig.getSchemaSP(), newConfig.getDocumentTypeRepoSP(), writer); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h index e1a374366d2..91405fb7117 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h @@ -1,13 +1,24 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "fast_access_feed_view.h" -#include <vespa/searchcore/proton/reprocessing/i_reprocessing_initializer.h> +#include <vespa/searchlib/common/serialnum.h> +#include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/varholder.h> +#include <memory> +#include <optional> + +namespace document { class DocumentTypeRepo; } +namespace search::index { class Schema; } namespace proton { +class AttributeCollectionSpecFactory; +class DocumentDBConfig; class DocumentSubDBReconfig; +class FastAccessFeedView; +class IAttributeWriter; +struct IReprocessingInitializer; class ReconfigParams; /** @@ -17,16 +28,16 @@ class ReconfigParams; class FastAccessDocSubDBConfigurer { public: - using FeedViewVarHolder = vespalib::VarHolder<FastAccessFeedView::SP>; + using FeedViewVarHolder = vespalib::VarHolder<std::shared_ptr<FastAccessFeedView>>; private: FeedViewVarHolder &_feedView; vespalib::string _subDbName; void reconfigureFeedView(FastAccessFeedView & curr, - search::index::Schema::SP schema, + std::shared_ptr<search::index::Schema> schema, std::shared_ptr<const document::DocumentTypeRepo> repo, - IAttributeWriter::SP attrWriter); + std::shared_ptr<IAttributeWriter> attrWriter); public: FastAccessDocSubDBConfigurer(FeedViewVarHolder &feedView, @@ -36,14 +47,16 @@ public: std::unique_ptr<DocumentSubDBReconfig> prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, + const AttributeCollectionSpecFactory& attr_spec_factory, const ReconfigParams& reconfig_params, + uint32_t docid_limit, std::optional<search::SerialNum> serial_num); - IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig, - const DocumentDBConfig &oldConfig, - const DocumentSubDBReconfig& prepared_reconfig, - search::SerialNum serial_num); + std::unique_ptr<IReprocessingInitializer> + reconfigure(const DocumentDBConfig &newConfig, + const DocumentDBConfig &oldConfig, + const DocumentSubDBReconfig& prepared_reconfig, + search::SerialNum serial_num); }; } // namespace proton 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 73faf03990d..f6a9d640f9b 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 @@ -3,7 +3,11 @@ #include "searchable_doc_subdb_configurer.h" #include "document_subdb_reconfig.h" #include "reconfig_params.h" +#include "searchable_feed_view.h" +#include "searchview.h" +#include <vespa/config-rank-profiles.h> #include <vespa/searchcore/proton/matching/matcher.h> +#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h> #include <vespa/searchcore/proton/attribute/attribute_manager_reconfig.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> @@ -29,11 +33,11 @@ using matching::OnnxModels; using ARIConfig = AttributeReprocessingInitializer::Config; void -SearchableDocSubDBConfigurer::reconfigureFeedView(IAttributeWriter::SP attrWriter, - Schema::SP schema, +SearchableDocSubDBConfigurer::reconfigureFeedView(std::shared_ptr<IAttributeWriter> attrWriter, + std::shared_ptr<Schema> schema, std::shared_ptr<const DocumentTypeRepo> repo) { - SearchableFeedView::SP curr = _feedView.get(); + auto curr = _feedView.get(); _feedView.set(std::make_shared<SearchableFeedView>( StoreOnlyFeedView::Context(curr->getSummaryAdapter(), std::move(schema), @@ -49,9 +53,9 @@ SearchableDocSubDBConfigurer::reconfigureFeedView(IAttributeWriter::SP attrWrite void SearchableDocSubDBConfigurer:: -reconfigureMatchView(const IndexSearchable::SP &indexSearchable) +reconfigureMatchView(const std::shared_ptr<IndexSearchable>& indexSearchable) { - SearchView::SP curr = _searchView.get(); + auto curr = _searchView.get(); reconfigureMatchView(curr->getMatchers(), indexSearchable, curr->getAttributeManager()); @@ -59,20 +63,20 @@ reconfigureMatchView(const IndexSearchable::SP &indexSearchable) void SearchableDocSubDBConfigurer:: -reconfigureMatchView(const Matchers::SP &matchers, - const IndexSearchable::SP &indexSearchable, - const IAttributeManager::SP &attrMgr) +reconfigureMatchView(const std::shared_ptr<Matchers>& matchers, + const std::shared_ptr<IndexSearchable>& indexSearchable, + const std::shared_ptr<IAttributeManager>& attrMgr) { - SearchView::SP curr = _searchView.get(); + auto curr = _searchView.get(); auto matchView = std::make_shared<MatchView>(matchers, indexSearchable, attrMgr, curr->getSessionManager(), curr->getDocumentMetaStore(), curr->getDocIdLimit()); reconfigureSearchView(matchView); } void -SearchableDocSubDBConfigurer::reconfigureSearchView(MatchView::SP matchView) +SearchableDocSubDBConfigurer::reconfigureSearchView(std::shared_ptr<MatchView> matchView) { - SearchView::SP curr = _searchView.get(); + auto curr = _searchView.get(); // make sure the initial search does not spend time waiting for // expression compilation completion during rank program setup. vespalib::eval::CompileCache::wait_pending(); @@ -80,14 +84,14 @@ SearchableDocSubDBConfigurer::reconfigureSearchView(MatchView::SP matchView) } void -SearchableDocSubDBConfigurer::reconfigureSearchView(ISummaryManager::ISummarySetup::SP summarySetup, - MatchView::SP matchView) +SearchableDocSubDBConfigurer::reconfigureSearchView(std::shared_ptr<ISummaryManager::ISummarySetup> summarySetup, + std::shared_ptr<MatchView> matchView) { _searchView.set(SearchView::create(std::move(summarySetup), std::move(matchView))); } SearchableDocSubDBConfigurer:: -SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, +SearchableDocSubDBConfigurer(const std::shared_ptr<ISummaryManager>& summaryMgr, SearchViewHolder &searchView, FeedViewHolder &feedView, matching::QueryLimiter &queryLimiter, @@ -135,17 +139,18 @@ SearchableDocSubDBConfigurer::createMatchers(const DocumentDBConfig& new_config_ void SearchableDocSubDBConfigurer::reconfigureIndexSearchable() { - SearchableFeedView::SP feedView(_feedView.get()); - const IIndexWriter::SP &indexWriter = feedView->getIndexWriter(); - const searchcorespi::IIndexManager::SP &indexManager = indexWriter->getIndexManager(); + auto feedView(_feedView.get()); + auto& indexWriter = feedView->getIndexWriter(); + auto& indexManager = indexWriter->getIndexManager(); reconfigureMatchView(indexManager->getSearchable()); } std::unique_ptr<DocumentSubDBReconfig> SearchableDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, + const AttributeCollectionSpecFactory& attr_spec_factory, const ReconfigParams& reconfig_params, + uint32_t docid_limit, std::optional<search::SerialNum> serial_num) { (void) old_config_snapshot; @@ -157,7 +162,8 @@ SearchableDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_confi reconfig->set_matchers(createMatchers(new_config_snapshot)); } if (reconfig_params.shouldAttributeManagerChange()) { - reconfig->set_attribute_manager_reconfig(old_attribute_manager->prepare_create(std::move(attr_spec))); + auto attr_spec = attr_spec_factory.create(new_config_snapshot.getAttributesConfig(), docid_limit, serial_num); + reconfig->set_attribute_manager_reconfig(old_attribute_manager->prepare_create(std::move(*attr_spec))); } return reconfig; } @@ -166,9 +172,9 @@ namespace { IReprocessingInitializer::UP createAttributeReprocessingInitializer(const DocumentDBConfig &newConfig, - const IAttributeManager::SP &newAttrMgr, + const std::shared_ptr<IAttributeManager>& newAttrMgr, const DocumentDBConfig &oldConfig, - const IAttributeManager::SP &oldAttrMgr, + const std::shared_ptr<IAttributeManager>& oldAttrMgr, const vespalib::string &subDbName, search::SerialNum serialNum) { @@ -197,17 +203,17 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, bool shouldMatchViewChange = prepared_reconfig.has_matchers_changed(); bool shouldSearchViewChange = false; bool shouldFeedViewChange = params.shouldSchemaChange(); - SearchView::SP searchView = _searchView.get(); + auto searchView = _searchView.get(); auto matchers = prepared_reconfig.matchers(); IReprocessingInitializer::UP initializer; - IAttributeManager::SP attrMgr = searchView->getAttributeManager(); - IAttributeWriter::SP attrWriter = _feedView.get()->getAttributeWriter(); + auto attrMgr = searchView->getAttributeManager(); + auto attrWriter = _feedView.get()->getAttributeWriter(); if (prepared_reconfig.has_attribute_manager_changed()) { auto newAttrMgr = prepared_reconfig.attribute_manager(); newAttrMgr->setImportedAttributes(resolver.resolve(*newAttrMgr, *attrMgr, searchView->getDocumentMetaStore(), newConfig.getMaintenanceConfigSP()->getVisibilityDelay())); - IAttributeManager::SP oldAttrMgr = attrMgr; + auto oldAttrMgr = attrMgr; attrMgr = newAttrMgr; shouldMatchViewChange = true; @@ -221,12 +227,12 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, shouldFeedViewChange = true; } - ISummaryManager::ISummarySetup::SP sumSetup = _searchView.get()->getSummarySetup(); + auto sumSetup = _searchView.get()->getSummarySetup(); if (params.shouldSummaryManagerChange() || params.shouldAttributeManagerChange()) { - ISummaryManager::SP sumMgr(_summaryMgr); - ISummaryManager::ISummarySetup::SP newSumSetup = + auto sumMgr(_summaryMgr); + auto newSumSetup = sumMgr->createSummarySetup(newConfig.getSummaryConfig(), newConfig.getJuniperrcConfig(), newConfig.getDocumentTypeRepoSP(), @@ -237,7 +243,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, } if (shouldMatchViewChange) { - IndexSearchable::SP indexSearchable = searchView->getIndexSearchable(); + auto indexSearchable = searchView->getIndexSearchable(); reconfigureMatchView(matchers, indexSearchable, attrMgr); searchView = _searchView.get(); } 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 196c48120c6..7cb9085f7a1 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 @@ -2,33 +2,35 @@ #pragma once -#include "isummaryadapter.h" -#include "matchers.h" -#include "matchview.h" -#include "searchable_feed_view.h" -#include "searchview.h" -#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/reprocessing/i_reprocessing_initializer.h> -#include <vespa/searchsummary/config/config-juniperrc.h> -#include <vespa/searchcommon/common/schema.h> -#include <vespa/config-attributes.h> -#include <vespa/config-indexschema.h> -#include <vespa/config-rank-profiles.h> -#include <vespa/config-summary.h> #include <vespa/vespalib/util/varholder.h> -#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h> + +namespace searchcorespi { class IndexSearchable; } namespace proton::matching { - class RankingExpressions; - class OnnxModels; + +class RankingExpressions; +class OnnxModels; +class QueryLimiter; + } + +namespace vespalib::eval { struct ConstantValueFactory; } +namespace vespalib { class Clock; } + namespace proton { +class AttributeCollectionSpecFactory; +class DocumentDBConfig; class DocumentSubDBReconfig; +class IAttributeWriter; struct IDocumentDBReferenceResolver; +struct IReprocessingInitializer; +class MatchView; +class Matchers; class ReconfigParams; +class SearchView; +class SearchableFeedView; /** * Class used to reconfig the feed view and search view used in a searchable sub database. @@ -36,9 +38,9 @@ class ReconfigParams; class SearchableDocSubDBConfigurer { private: - using SearchViewHolder = vespalib::VarHolder<SearchView::SP>; - using FeedViewHolder = vespalib::VarHolder<SearchableFeedView::SP>; - const ISummaryManager::SP &_summaryMgr; + using SearchViewHolder = vespalib::VarHolder<std::shared_ptr<SearchView>>; + using FeedViewHolder = vespalib::VarHolder<std::shared_ptr<SearchableFeedView>>; + const std::shared_ptr<ISummaryManager>& _summaryMgr; SearchViewHolder &_searchView; FeedViewHolder &_feedView; matching::QueryLimiter &_queryLimiter; @@ -47,24 +49,24 @@ private: vespalib::string _subDbName; uint32_t _distributionKey; - void reconfigureFeedView(IAttributeWriter::SP attrWriter, - search::index::Schema::SP schema, + void reconfigureFeedView(std::shared_ptr<IAttributeWriter> attrWriter, + std::shared_ptr<search::index::Schema> schema, std::shared_ptr<const document::DocumentTypeRepo> repo); - void reconfigureMatchView(const searchcorespi::IndexSearchable::SP &indexSearchable); + void reconfigureMatchView(const std::shared_ptr<searchcorespi::IndexSearchable>& indexSearchable); - void reconfigureMatchView(const Matchers::SP &matchers, - const searchcorespi::IndexSearchable::SP &indexSearchable, - const IAttributeManager::SP &attrMgr); + void reconfigureMatchView(const std::shared_ptr<Matchers>& matchers, + const std::shared_ptr<searchcorespi::IndexSearchable>& indexSearchable, + const std::shared_ptr<IAttributeManager>& attrMgr); - void reconfigureSearchView(MatchView::SP matchView); + void reconfigureSearchView(std::shared_ptr<MatchView> matchView); - void reconfigureSearchView(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView); + void reconfigureSearchView(std::shared_ptr<ISummaryManager::ISummarySetup> summarySetup, std::shared_ptr<MatchView> matchView); public: SearchableDocSubDBConfigurer(const SearchableDocSubDBConfigurer &) = delete; SearchableDocSubDBConfigurer & operator = (const SearchableDocSubDBConfigurer &) = delete; - SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, + SearchableDocSubDBConfigurer(const std::shared_ptr<ISummaryManager>& summaryMgr, SearchViewHolder &searchView, FeedViewHolder &feedView, matching::QueryLimiter &queryLimiter, @@ -74,18 +76,19 @@ public: uint32_t distributionKey); ~SearchableDocSubDBConfigurer(); - Matchers::SP createMatchers(const DocumentDBConfig& new_config_snapshot); + std::shared_ptr<Matchers> createMatchers(const DocumentDBConfig& new_config_snapshot); void reconfigureIndexSearchable(); std::unique_ptr<DocumentSubDBReconfig> prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, - AttributeCollectionSpec&& attr_spec, + const AttributeCollectionSpecFactory& attr_spec_factory, const ReconfigParams& reconfig_params, + uint32_t docid_limit, std::optional<search::SerialNum> serial_num); - IReprocessingInitializer::UP + std::unique_ptr<IReprocessingInitializer> reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, const ReconfigParams ¶ms, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 33e4560d542..0f98f2c106c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -6,6 +6,7 @@ #include "document_subdb_reconfig.h" #include "reconfig_params.h" #include "i_document_subdb_owner.h" +#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/common/alloc_config.h> #include <vespa/searchcore/proton/flushengine/threadedflushtarget.h> @@ -13,6 +14,8 @@ #include <vespa/searchcore/proton/index/index_writer.h> #include <vespa/searchcore/proton/reference/document_db_reference.h> #include <vespa/searchcore/proton/reference/gid_to_lid_change_handler.h> +#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h> +#include <vespa/searchcore/proton/reprocessing/i_reprocessing_initializer.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/eval/eval/fast_value.h> @@ -136,8 +139,9 @@ std::unique_ptr<DocumentSubDBReconfig> SearchableDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional<SerialNum> serial_num) { auto alloc_strategy = new_config_snapshot.get_alloc_config().make_alloc_strategy(_subDbType); - auto attr_spec = createAttributeSpec(new_config_snapshot.getAttributesConfig(), alloc_strategy, serial_num); - return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, std::move(*attr_spec), reconfig_params, serial_num); + AttributeCollectionSpecFactory attr_spec_factory(alloc_strategy, get_fast_access_attributes_only()); + auto docid_limit = _dms->getCommittedDocIdLimit(); + return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, attr_spec_factory, reconfig_params, docid_limit, serial_num); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 522ccd69b2a..0f3c1f19ddb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -8,6 +8,7 @@ #include "summaryadapter.h" #include "igetserialnum.h" #include "document_db_flush_config.h" +#include <vespa/config-rank-profiles.h> #include <vespa/eval/eval/value_cache/constant_tensor_loader.h> #include <vespa/eval/eval/value_cache/constant_value_cache.h> #include <vespa/searchcore/proton/attribute/attributemanager.h> |