From 77f6d4dcbc131d3b2c0230b3b772ffeba7461453 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Thu, 10 Oct 2024 22:48:11 +0200 Subject: [PATCH 1/2] Use shared_ptr to const Schema when schema is considered to be immutable. --- .../src/tests/proton/documentdb/configurer_test.cpp | 8 ++++---- .../tests/proton/documentdb/documentdbconfig_test.cpp | 6 +++--- .../proton/documentdb/documentdbconfigscout_test.cpp | 6 +++--- .../src/tests/proton/documentdb/feedview_test.cpp | 2 +- .../tests/proton/documentdb/storeonlyfeedview_test.cpp | 2 +- .../proton_configurer/proton_configurer_test.cpp | 2 +- .../src/tests/proton/server/memoryconfigstore_test.cpp | 6 +++--- .../vespa/searchcore/proton/index/memoryindexwrapper.h | 2 +- .../src/vespa/searchcore/proton/server/documentdb.cpp | 1 - .../searchcore/proton/server/documentdbconfig.cpp | 6 +++--- .../vespa/searchcore/proton/server/documentdbconfig.h | 8 ++++---- .../proton/server/documentdbconfigmanager.cpp | 6 +++--- .../searchcore/proton/server/documentdbconfigmanager.h | 2 +- .../proton/server/fast_access_doc_subdb_configurer.cpp | 2 +- .../proton/server/fast_access_doc_subdb_configurer.h | 2 +- .../vespa/searchcore/proton/server/idocumentsubdb.h | 3 +-- .../proton/server/searchable_doc_subdb_configurer.cpp | 2 +- .../proton/server/searchable_doc_subdb_configurer.h | 2 +- .../searchcore/proton/server/searchabledocsubdb.cpp | 2 +- .../searchcore/proton/server/searchabledocsubdb.h | 2 +- .../searchcore/proton/server/storeonlydocsubdb.cpp | 2 +- .../vespa/searchcore/proton/server/storeonlydocsubdb.h | 2 +- .../vespa/searchcore/proton/server/storeonlyfeedview.h | 8 ++++---- .../proton/test/documentdb_config_builder.cpp | 4 ++-- .../searchcore/proton/test/documentdb_config_builder.h | 4 ++-- .../searchcore/proton/test/dummy_document_sub_db.h | 2 +- .../src/vespa/searchcorespi/index/imemoryindex.h | 2 +- .../src/vespa/searchcorespi/index/indexmaintainer.cpp | 8 ++++---- .../src/vespa/searchcorespi/index/indexmaintainer.h | 10 +++++----- searchlib/src/vespa/searchcommon/common/schema.h | 1 - .../src/vespa/searchlib/memoryindex/memory_index.cpp | 2 +- .../src/vespa/searchlib/memoryindex/memory_index.h | 4 ++-- 32 files changed, 59 insertions(+), 62 deletions(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer_test.cpp index 2e32b6acbebf..2139ea576bbd 100644 --- a/searchcore/src/tests/proton/documentdb/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer_test.cpp @@ -228,7 +228,7 @@ Fixture::initViewSet(ViewSet &views) auto attrWriter = std::make_shared(attrMgr); auto summaryAdapter = std::make_shared(summaryMgr); views._gidToLidChangeHandler = make_shared(); - Schema::SP schema(new Schema()); + std::shared_ptr schema(std::make_shared()); views._summaryMgr = summaryMgr; views._dmsc = metaStore; IndexSearchable::SP indexSearchable; @@ -318,7 +318,7 @@ MyFastAccessFeedView::~MyFastAccessFeedView() = default; void MyFastAccessFeedView::init() { MySummaryAdapter::SP summaryAdapter = std::make_shared(); - Schema::SP schema = std::make_shared(); + std::shared_ptr schema = std::make_shared(); _dmsc = make_shared(std::make_shared()); std::shared_ptr repo = createRepo(); StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, repo, @@ -382,9 +382,9 @@ createConfig() } DocumentDBConfig::SP -createConfig(const Schema::SP &schema) +createConfig(std::shared_ptr schema) { - return proton::test::DocumentDBConfigBuilder(0, schema, "client", DOC_TYPE). + return proton::test::DocumentDBConfigBuilder(0, std::move(schema), "client", DOC_TYPE). repo(createRepo()).build(); } diff --git a/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp b/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp index 7826a7fa176a..fbbf6097b062 100644 --- a/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp @@ -54,8 +54,8 @@ class MyConfigBuilder { test::DocumentDBConfigBuilder _builder; public: - MyConfigBuilder(int64_t generation, const Schema::SP &schema, const std::shared_ptr &repo) - : _builder(generation, schema, "client", "test") + MyConfigBuilder(int64_t generation, std::shared_ptr schema, const std::shared_ptr &repo) + : _builder(generation, std::move(schema), "client", "test") { _builder.repo(repo); } @@ -170,7 +170,7 @@ TEST_F("require that makeReplayConfig() drops unneeded configs", Fixture) } struct DelayAttributeAspectFixture { - Schema::SP schema; + std::shared_ptr schema; ConfigSP attrCfg; ConfigSP noAttrCfg; explicit DelayAttributeAspectFixture(bool hasDocField) diff --git a/searchcore/src/tests/proton/documentdb/documentdbconfigscout_test.cpp b/searchcore/src/tests/proton/documentdb/documentdbconfigscout_test.cpp index a1d3784ca44a..89141bef94de 100644 --- a/searchcore/src/tests/proton/documentdb/documentdbconfigscout_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdbconfigscout_test.cpp @@ -41,11 +41,11 @@ std::ostream& operator<<(std::ostream& os, const AttributesConfig::Attribute::Di namespace { DDBCSP -getConfig(int64_t generation, const Schema::SP &schema, +getConfig(int64_t generation, std::shared_ptr schema, const shared_ptr & repo, const AttributesConfig &attributes) { - return test::DocumentDBConfigBuilder(generation, schema, "client", "test"). + return test::DocumentDBConfigBuilder(generation, std::move(schema), "client", "test"). repo(repo).attributes(make_shared(attributes)).build(); } @@ -382,7 +382,7 @@ TEST("Test that DocumentDBConfigScout::scout looks ahead") setupLiveAttributes(liveAttributes.attribute); shared_ptr repo(make_shared()); - Schema::SP schema(make_shared()); + std::shared_ptr schema(make_shared()); DDBCSP cfg = getConfig(4, schema, repo, attributes); DDBCSP liveCfg = getConfig(4, schema, repo, liveAttributes); EXPECT_FALSE(*cfg == *liveCfg); diff --git a/searchcore/src/tests/proton/documentdb/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview_test.cpp index 81d293a26e43..d6378a38a6c0 100644 --- a/searchcore/src/tests/proton/documentdb/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview_test.cpp @@ -433,7 +433,7 @@ MyTransport::~MyTransport() = default; struct SchemaContext { DocBuilder _builder; - Schema::SP _schema; + std::shared_ptr _schema; SchemaContext(); ~SchemaContext(); std::shared_ptr getRepo() const { return _builder.get_repo_sp(); } diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp index 8938f1a07457..8006fffe8e81 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp @@ -90,7 +90,7 @@ struct MyMinimalFeedView : public MyMinimalFeedViewBase, public StoreOnlyFeedVie std::atomic &outstandingMoveOps_) : MyMinimalFeedViewBase(), StoreOnlyFeedView(StoreOnlyFeedView::Context(summaryAdapter, - search::index::Schema::SP(), + {}, std::make_shared(metaStore), myGetDocumentTypeRepo(), std::move(pendingLidsForCommit), diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp index 586199e4046e..447c51f9c969 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -53,7 +53,7 @@ struct DBConfigFixture { JuniperrcConfigBuilder _juniperrcBuilder; ImportedFieldsConfigBuilder _importedFieldsBuilder; - Schema::SP buildSchema() + std::shared_ptr buildSchema() { return DocumentDBConfig::build_schema(_attributesBuilder, _indexschemaBuilder); } diff --git a/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp b/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp index ccb893b65a25..889df15ea679 100644 --- a/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp +++ b/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp @@ -15,16 +15,16 @@ using namespace proton; namespace { DocumentDBConfig::SP -getConfig(int64_t generation, const Schema::SP &schema) +getConfig(int64_t generation, std::shared_ptr schema) { - return test::DocumentDBConfigBuilder(generation, schema, "client", "test").build(); + return test::DocumentDBConfigBuilder(generation, std::move(schema), "client", "test").build(); } DocumentDBConfig::SP getConfig(int64_t generation) { - return getConfig(generation, Schema::SP()); + return getConfig(generation, {}); } diff --git a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h index 0a11dbbdb573..ba6724feb61c 100644 --- a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h +++ b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h @@ -71,7 +71,7 @@ class MemoryIndexWrapper : public searchcorespi::index::IMemoryIndex { bool hasReceivedDocumentInsert() const override { return _index.getDocIdLimit() > 1u; } - search::index::Schema::SP getPrunedSchema() const override { + std::shared_ptr getPrunedSchema() const override { return _index.getPrunedSchema(); } vespalib::MemoryUsage getMemoryUsage() const override { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 4263fabdd05b..5b9a7d495723 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -431,7 +431,6 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum auto start_time = vespalib::steady_clock::now(); DocumentDBConfig::ComparisonResult cmpres; - Schema::SP oldSchema; { lock_guard guard(_configMutex); assert(_activeConfigSnapshot.get()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp index 659e86967520..93a9b33b4ddd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp @@ -66,7 +66,7 @@ DocumentDBConfig::DocumentDBConfig( const std::shared_ptr &repo, const ImportedFieldsConfigSP &importedFields, const search::TuneFileDocumentDB::SP &tuneFileDocumentDB, - const Schema::SP &schema, + std::shared_ptr schema, const DocumentDBMaintenanceConfig::SP &maintenance, const search::LogDocumentStore::Config & storeConfig, const ThreadingServiceConfig & threading_service_config, @@ -88,7 +88,7 @@ DocumentDBConfig::DocumentDBConfig( _repo(repo), _importedFields(importedFields), _tuneFileDocumentDB(tuneFileDocumentDB), - _schema(schema), + _schema(std::move(schema)), _maintenance(maintenance), _storeConfig(storeConfig), _threading_service_config(threading_service_config), @@ -338,7 +338,7 @@ DocumentDBConfig::getDocumentType() const return _repo->getDocumentType(getDocTypeName()); } -std::shared_ptr +std::shared_ptr DocumentDBConfig::build_schema(const AttributesConfig& attributes_config, const IndexschemaConfig &indexschema_config) { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h index fe72c35b1407..86b32dd50e97 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h @@ -126,7 +126,7 @@ class DocumentDBConfig std::shared_ptr _repo; ImportedFieldsConfigSP _importedFields; search::TuneFileDocumentDB::SP _tuneFileDocumentDB; - search::index::Schema::SP _schema; + std::shared_ptr _schema; MaintenanceConfigSP _maintenance; search::LogDocumentStore::Config _storeConfig; const ThreadingServiceConfig _threading_service_config; @@ -165,7 +165,7 @@ class DocumentDBConfig const std::shared_ptr &repo, const ImportedFieldsConfigSP &importedFields, const search::TuneFileDocumentDB::SP &tuneFileDocumentDB, - const search::index::Schema::SP &schema, + std::shared_ptr schema, const DocumentDBMaintenanceConfig::SP &maintenance, const search::LogDocumentStore::Config & storeConfig, const ThreadingServiceConfig & threading_service_config, @@ -206,7 +206,7 @@ class DocumentDBConfig const document::DocumentType *getDocumentType() const; const ImportedFieldsConfig &getImportedFieldsConfig() const { return *_importedFields; } const ImportedFieldsConfigSP &getImportedFieldsConfigSP() const { return _importedFields; } - const search::index::Schema::SP &getSchemaSP() const { return _schema; } + const std::shared_ptr& getSchemaSP() const noexcept { return _schema; } const MaintenanceConfigSP &getMaintenanceConfigSP() const { return _maintenance; } const search::TuneFileDocumentDB::SP &getTuneFileDocumentDBSP() const { return _tuneFileDocumentDB; } bool getDelayedAttributeAspects() const { return _delayedAttributeAspects; } @@ -253,7 +253,7 @@ class DocumentDBConfig static SP makeDelayedAttributeAspectConfig(const SP &newCfg, const DocumentDBConfig &oldCfg); SP make_copy() const; - static std::shared_ptr + static std::shared_ptr build_schema(const AttributesConfig& attributes_config, const IndexschemaConfig &indexschema_config); }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index 3557cc01aeae..83744c775802 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -69,12 +69,12 @@ DocumentDBConfigManager::createConfigKeySet() const return set; } -Schema::SP +std::shared_ptr DocumentDBConfigManager::buildSchema(const AttributesConfig &newAttributesConfig, const IndexschemaConfig &newIndexschemaConfig) { // Called with lock held - Schema::SP oldSchema; + std::shared_ptr oldSchema; if (_pendingConfigSnapshot) { oldSchema = _pendingConfigSnapshot->getSchemaSP(); } @@ -335,7 +335,7 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot JuniperrcConfigSP newJuniperrcConfig = snapshot.getConfig(_configId); ImportedFieldsConfigSP newImportedFieldsConfig = snapshot.getConfig(_configId); - Schema::SP schema(buildSchema(*newAttributesConfig, *newIndexschemaConfig)); + auto schema(buildSchema(*newAttributesConfig, *newIndexschemaConfig)); newMaintenanceConfig = buildMaintenanceConfig(_bootstrapConfig, _docTypeName); search::LogDocumentStore::Config storeConfig = buildStoreConfig(_bootstrapConfig->getProtonConfig(), _bootstrapConfig->getHwInfo()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h index 6facd65057f7..c1923637d28c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h @@ -32,7 +32,7 @@ class DocumentDBConfigManager bool _ignoreForwardedConfig; mutable std::mutex _pendingConfigMutex; - search::index::Schema::SP + std::shared_ptr buildSchema(const DocumentDBConfig::AttributesConfig & newAttributesConfig, const DocumentDBConfig::IndexschemaConfig & newIndexschemaConfig); 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 8c7367482a36..6b7a2afa23cb 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 @@ -22,7 +22,7 @@ using ARIConfig = AttributeReprocessingInitializer::Config; void FastAccessDocSubDBConfigurer::reconfigureFeedView(FastAccessFeedView & curr, - std::shared_ptr schema, + std::shared_ptr schema, std::shared_ptr repo, std::shared_ptr 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 af6074905e42..3c05648fb256 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 @@ -35,7 +35,7 @@ class FastAccessDocSubDBConfigurer std::string _subDbName; void reconfigureFeedView(FastAccessFeedView & curr, - std::shared_ptr schema, + std::shared_ptr schema, std::shared_ptr repo, std::shared_ptr attrWriter); diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index 81efe9c00c84..d5eaf2db2e74 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -62,7 +62,6 @@ class IDocumentSubDB using UP = std::unique_ptr; using SerialNum = search::SerialNum; using Schema = search::index::Schema; - using SchemaSP = std::shared_ptr; using IFlushTargetList = std::vector>; using IndexConfig = index::IndexConfig; using OnDone = std::shared_ptr; @@ -122,7 +121,7 @@ class IDocumentSubDB */ virtual SerialNum getNewestFlushedSerial() = 0; virtual void pruneRemovedFields(SerialNum serialNum) = 0; - virtual void setIndexSchema(const SchemaSP &schema, SerialNum serialNum) = 0; + virtual void setIndexSchema(std::shared_ptr schema, SerialNum serialNum) = 0; virtual search::SearchableStats getSearchableStats() const = 0; virtual std::shared_ptr getDocumentRetriever() = 0; 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 412596a7848f..fe698c335288 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 @@ -33,7 +33,7 @@ using ARIConfig = AttributeReprocessingInitializer::Config; void SearchableDocSubDBConfigurer::reconfigureFeedView(std::shared_ptr attrWriter, - std::shared_ptr schema, + std::shared_ptr schema, std::shared_ptr repo) { auto curr = _feedView.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 793e011a5db9..27c772dcd995 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 @@ -51,7 +51,7 @@ class SearchableDocSubDBConfigurer uint32_t _distributionKey; void reconfigureFeedView(std::shared_ptr attrWriter, - std::shared_ptr schema, + std::shared_ptr schema, std::shared_ptr repo); void reconfigureMatchView(const std::shared_ptr& indexSearchable); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index a4bbfdc3413a..55f5819970ed 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -283,7 +283,7 @@ SearchableDocSubDB::getFlushTargetsInternal() } void -SearchableDocSubDB::setIndexSchema(const Schema::SP &schema, SerialNum serialNum) +SearchableDocSubDB::setIndexSchema(std::shared_ptr schema, SerialNum serialNum) { assert(_writeService.master().isCurrentThread()); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 6986908995c4..1836e45e86b3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -126,7 +126,7 @@ SearchableDocSubDB : public FastAccessDocSubDB, SerialNum getOldestFlushedSerial() override; SerialNum getNewestFlushedSerial() override; - void setIndexSchema(const Schema::SP &schema, SerialNum serialNum) override; + void setIndexSchema(std::shared_ptr schema, SerialNum serialNum) override; size_t getNumActiveDocs() const override; search::SearchableStats getSearchableStats() const override ; std::shared_ptr getDocumentRetriever() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 8bf10fe18dc5..21ed93274c50 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -537,7 +537,7 @@ StoreOnlyDocSubDB::pruneRemovedFields(SerialNum) } void -StoreOnlyDocSubDB::setIndexSchema(const Schema::SP &, SerialNum ) +StoreOnlyDocSubDB::setIndexSchema(std::shared_ptr, SerialNum) { assert(_writeService.master().isCurrentThread()); } diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index a86b8af40d98..182234bb86d8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -230,7 +230,7 @@ class StoreOnlyDocSubDB : public DocSubDB SerialNum getNewestFlushedSerial() override; void pruneRemovedFields(SerialNum serialNum) override; - void setIndexSchema(const Schema::SP &schema, SerialNum serialNum) override; + void setIndexSchema(std::shared_ptr schema, SerialNum serialNum) override; search::SearchableStats getSearchableStats() const override; std::shared_ptr getDocumentRetriever() override; matching::MatchingStats getMatcherStats(const std::string &rankProfile) const override; diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h index 0e1a4e09482a..542bbb5e7fd7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h @@ -71,7 +71,7 @@ class StoreOnlyFeedView : public IFeedView, struct Context { ISummaryAdapter::SP _summaryAdapter; - search::index::Schema::SP _schema; + std::shared_ptr _schema; IDocumentMetaStoreContext::SP _documentMetaStoreContext; std::shared_ptr _repo; std::shared_ptr _pendingLidsForCommit; @@ -79,7 +79,7 @@ class StoreOnlyFeedView : public IFeedView, searchcorespi::index::IThreadingService &_writeService; Context(ISummaryAdapter::SP summaryAdapter, - search::index::Schema::SP schema, + std::shared_ptr schema, IDocumentMetaStoreContext::SP documentMetaStoreContext, std::shared_ptr repo, std::shared_ptr pendingLidsForCommit, @@ -126,7 +126,7 @@ class StoreOnlyFeedView : public IFeedView, LidReuseDelayer _lidReuseDelayer; PendingLidTracker _pendingLidsForDocStore; std::shared_ptr _pendingLidsForCommit; - const search::index::Schema::SP _schema; + const std::shared_ptr _schema; vespalib::hash_set _indexedFields; protected: searchcorespi::index::IThreadingService &_writeService; @@ -197,7 +197,7 @@ class StoreOnlyFeedView : public IFeedView, ~StoreOnlyFeedView() override; const ISummaryAdapter::SP &getSummaryAdapter() const { return _summaryAdapter; } - const search::index::Schema::SP &getSchema() const { return _schema; } + const std::shared_ptr &getSchema() const noexcept { return _schema; } const PersistentParams &getPersistentParams() const { return _params; } const search::IDocumentStore &getDocumentStore() const { return _summaryAdapter->getDocumentStore(); } const IDocumentMetaStoreContext::SP &getDocumentMetaStore() const { return _documentMetaStoreContext; } diff --git a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp index c2da87fd9cfc..789e893b0358 100644 --- a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp +++ b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp @@ -26,7 +26,7 @@ using proton::ThreadingServiceConfig; namespace proton::test { DocumentDBConfigBuilder::DocumentDBConfigBuilder(int64_t generation, - const search::index::Schema::SP &schema, + std::shared_ptr schema, const std::string &configId, const std::string &docTypeName) : _generation(generation), @@ -42,7 +42,7 @@ DocumentDBConfigBuilder::DocumentDBConfigBuilder(int64_t generation, _repo(std::make_shared()), _importedFields(std::make_shared()), _tuneFileDocumentDB(std::make_shared()), - _schema(schema), + _schema(std::move(schema)), _maintenance(std::make_shared()), _store(), _threading_service_config(ThreadingServiceConfig::make()), diff --git a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h index 7a1a3951ebed..3924febf9553 100644 --- a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h +++ b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h @@ -27,7 +27,7 @@ class DocumentDBConfigBuilder { std::shared_ptr _repo; DocumentDBConfig::ImportedFieldsConfigSP _importedFields; search::TuneFileDocumentDB::SP _tuneFileDocumentDB; - search::index::Schema::SP _schema; + std::shared_ptr _schema; DocumentDBConfig::MaintenanceConfigSP _maintenance; search::LogDocumentStore::Config _store; const ThreadingServiceConfig _threading_service_config; @@ -37,7 +37,7 @@ class DocumentDBConfigBuilder { public: DocumentDBConfigBuilder(int64_t generation, - const search::index::Schema::SP &schema, + std::shared_ptr schema, const std::string &configId, const std::string &docTypeName); ~DocumentDBConfigBuilder(); diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index 990852d843d4..7155e120a12f 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -73,7 +73,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB SerialNum getOldestFlushedSerial() override { return 0; } SerialNum getNewestFlushedSerial() override { return 0; } void pruneRemovedFields(SerialNum) override { } - void setIndexSchema(const Schema::SP &, SerialNum) override { } + void setIndexSchema(std::shared_ptr, SerialNum) override { } search::SearchableStats getSearchableStats() const override { return {}; } diff --git a/searchcore/src/vespa/searchcorespi/index/imemoryindex.h b/searchcore/src/vespa/searchcorespi/index/imemoryindex.h index d9a13e24a1aa..4cfb37cb1ea2 100644 --- a/searchcore/src/vespa/searchcorespi/index/imemoryindex.h +++ b/searchcore/src/vespa/searchcorespi/index/imemoryindex.h @@ -78,7 +78,7 @@ struct IMemoryIndex : public searchcorespi::IndexSearchable { search::SerialNum serialNum) = 0; virtual void pruneRemovedFields(const search::index::Schema &schema) = 0; - virtual search::index::Schema::SP getPrunedSchema() const = 0; + virtual std::shared_ptr getPrunedSchema() const = 0; virtual void insert_write_context_state(vespalib::slime::Cursor& object) const = 0; }; diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp index 1ab09c0e0495..9fa489b31782 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp +++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp @@ -269,9 +269,9 @@ IndexMaintainer::updateActiveFusionPrunedSchema(const Schema &schema) { assert(_ctx.getThreadingService().master().isCurrentThread()); for (;;) { - std::shared_ptr activeFusionSchema; - std::shared_ptr activeFusionPrunedSchema; - std::shared_ptr newActiveFusionPrunedSchema; + std::shared_ptr activeFusionSchema; + std::shared_ptr activeFusionPrunedSchema; + std::shared_ptr newActiveFusionPrunedSchema; { LockGuard lock(_state_lock); activeFusionSchema = _activeFusionSchema; @@ -822,7 +822,7 @@ IndexMaintainer::getSchema(void) const return _schema; } -std::shared_ptr +std::shared_ptr IndexMaintainer::getActiveFusionPrunedSchema(void) const { LockGuard lock(_index_update_lock); diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h index ff6a6a791333..3e55f75a5d34 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h +++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h @@ -76,9 +76,9 @@ class IndexMaintainer : public IIndexManager, std::shared_ptr _disk_indexes; IndexDiskLayout _layout; Schema _schema; // Protected by SL + IUL - std::shared_ptr _activeFusionSchema; // Protected by SL + IUL + std::shared_ptr _activeFusionSchema; // Protected by SL + IUL // Protected by SL + IUL - std::shared_ptr _activeFusionPrunedSchema; + std::shared_ptr _activeFusionPrunedSchema; uint32_t _source_selector_changes; // Protected by IUL // _selector is protected by SL + IUL std::shared_ptr _selector; @@ -196,7 +196,7 @@ class IndexMaintainer : public IIndexManager, // or data structure limitations). FrozenMemoryIndexRefs _extraIndexes; ChangeGens _changeGens; - std::shared_ptr _prunedSchema; + std::shared_ptr _prunedSchema; FlushArgs(); FlushArgs(const FlushArgs &) = delete; @@ -222,7 +222,7 @@ class IndexMaintainer : public IIndexManager, uint32_t _new_fusion_id; ChangeGens _changeGens; Schema _schema; - std::shared_ptr _prunedSchema; + std::shared_ptr _prunedSchema; std::shared_ptr _old_source_list; // Delays destruction FusionArgs(); @@ -247,7 +247,7 @@ class IndexMaintainer : public IIndexManager, void doneSetSchema(SetSchemaArgs &args, std::shared_ptr& newIndex, SerialNum serial_num); Schema getSchema(void) const; - std::shared_ptr getActiveFusionPrunedSchema() const; + std::shared_ptr getActiveFusionPrunedSchema() const; search::TuneFileAttributes getAttrTune(); ChangeGens getChangeGens(); diff --git a/searchlib/src/vespa/searchcommon/common/schema.h b/searchlib/src/vespa/searchcommon/common/schema.h index 4649decaa5fa..2c3e9bff711e 100644 --- a/searchlib/src/vespa/searchcommon/common/schema.h +++ b/searchlib/src/vespa/searchcommon/common/schema.h @@ -17,7 +17,6 @@ class Schema { public: using UP = std::unique_ptr; - using SP = std::shared_ptr; using DataType = schema::DataType; using CollectionType = schema::CollectionType; diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp index 2e53b306d0c3..f98fc80b9599 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp @@ -236,7 +236,7 @@ MemoryIndex::pruneRemovedFields(const Schema &schema) } } -Schema::SP +std::shared_ptr MemoryIndex::getPrunedSchema() const { std::lock_guard lock(_lock); diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h index 6ac34657ad73..48c356eaaae2 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h @@ -57,7 +57,7 @@ class MemoryIndex : public queryeval::Searchable { std::atomic _numDocs; mutable std::mutex _lock; std::vector _hiddenFields; - index::Schema::SP _prunedSchema; + std::shared_ptr _prunedSchema; vespalib::hash_set _indexedDocs; // documents in memory index const uint64_t _staticMemoryFootprint; @@ -165,7 +165,7 @@ class MemoryIndex : public queryeval::Searchable { void pruneRemovedFields(const index::Schema &schema); - index::Schema::SP getPrunedSchema() const; + std::shared_ptr getPrunedSchema() const; /** * Gets an approximation of how much memory the index uses. From 66dcdac55eca794f28a696bfb1fd762b2625e72a Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 11 Oct 2024 11:47:08 +0200 Subject: [PATCH 2/2] Use const template argument to std::make_shared when appropriate. --- searchcore/src/tests/proton/documentdb/configurer_test.cpp | 4 ++-- .../documentdb/fileconfigmanager/fileconfigmanager_test.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer_test.cpp index 2139ea576bbd..fffe2edb6b06 100644 --- a/searchcore/src/tests/proton/documentdb/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer_test.cpp @@ -228,7 +228,7 @@ Fixture::initViewSet(ViewSet &views) auto attrWriter = std::make_shared(attrMgr); auto summaryAdapter = std::make_shared(summaryMgr); views._gidToLidChangeHandler = make_shared(); - std::shared_ptr schema(std::make_shared()); + auto schema(std::make_shared()); views._summaryMgr = summaryMgr; views._dmsc = metaStore; IndexSearchable::SP indexSearchable; @@ -318,7 +318,7 @@ MyFastAccessFeedView::~MyFastAccessFeedView() = default; void MyFastAccessFeedView::init() { MySummaryAdapter::SP summaryAdapter = std::make_shared(); - std::shared_ptr schema = std::make_shared(); + auto schema = std::make_shared(); _dmsc = make_shared(std::make_shared()); std::shared_ptr repo = createRepo(); StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, repo, diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index 1b195c1ab8a9..0820e808ab7d 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -73,7 +73,7 @@ saveBaseConfigSnapshot(FNET_Transport & transport, const DocumentDBConfig &snap, DocumentDBConfig::SP makeEmptyConfigSnapshot() { - return test::DocumentDBConfigBuilder(0, std::make_shared(), "client", "test").build(); + return test::DocumentDBConfigBuilder(0, std::make_shared(), "client", "test").build(); } void