diff options
11 files changed, 68 insertions, 18 deletions
diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index c3721b0064b..1aa85baccb7 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -22,6 +22,7 @@ LOG_SETUP("persistenceconformance_test"); #include <tests/proton/common/dummydbowner.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/searchcore/proton/common/hw_info.h> +#include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> using namespace config; @@ -107,12 +108,15 @@ public: SchemaBuilder::build(*indexschema, *schema); SchemaBuilder::build(*attributes, *schema); SchemaBuilder::build(*summary, *schema); + AttributeSpecsBuilder attributeSpecsBuilder; + attributeSpecsBuilder.setup(*attributes); return DocumentDBConfig::SP(new DocumentDBConfig( 1, std::make_shared<RankProfilesConfig>(), std::make_shared<matching::RankingConstants>(), indexschema, - attributes, + attributeSpecsBuilder.getAttributesConfig(), + attributeSpecsBuilder.getAttributeSpecs(), summary, std::make_shared<SummarymapConfig>(), std::make_shared<JuniperrcConfig>(), diff --git a/searchcore/src/tests/proton/attribute/attribute_specs_builder/attribute_specs_builder_test.cpp b/searchcore/src/tests/proton/attribute/attribute_specs_builder/attribute_specs_builder_test.cpp index 0e60f9c9004..379c9282b67 100644 --- a/searchcore/src/tests/proton/attribute/attribute_specs_builder/attribute_specs_builder_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_specs_builder/attribute_specs_builder_test.cpp @@ -6,6 +6,7 @@ LOG_SETUP("attribute_specs_builder_test"); #include <vespa/vespalib/stllike/string.h> #include <vespa/searchcore/proton/test/attribute_utils.h> #include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> +#include <vespa/searchcore/proton/attribute/attribute_specs.h> #include <vespa/searchcore/proton/common/i_document_type_inspector.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/config-indexschema.h> @@ -173,8 +174,8 @@ public: } void assertSpecs(const std::vector<AttributeSpec> &expSpecs) { - auto &actSpecs = _builder.getAttributeSpecs(); - EXPECT_EQUAL(expSpecs, actSpecs.getSpecs()); + const auto &actSpecs = _builder.getAttributeSpecs(); + EXPECT_EQUAL(expSpecs, actSpecs->getSpecs()); } void assertConfigs(const std::vector<AttributesConfig::Attribute> &exp) { diff --git a/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp b/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp index 21c211f4a73..7c49956ea69 100644 --- a/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp @@ -6,6 +6,7 @@ #include <vespa/config-rank-profiles.h> #include <vespa/config-imported-fields.h> #include <vespa/config-attributes.h> +#include <vespa/searchcore/proton/attribute/attribute_specs.h> using namespace document; using namespace proton; @@ -100,4 +101,11 @@ TEST_F("require that makeReplayConfig() drops unneeded configs", Fixture) EXPECT_TRUE(DDBC::preferOriginalConfig(f.nullCfg).get() == nullptr); } +TEST_F("require that attribute spec is setup", Fixture) +{ + const auto &attributeSpecs = f.fullCfg->getAttributeSpecs().getSpecs(); + EXPECT_EQUAL(1, attributeSpecs.size()); + EXPECT_EQUAL("my_attribute", attributeSpecs[0].getName()); +} + TEST_MAIN() { TEST_RUN_ALL(); } 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 7a8247c8944..2ddb1752d24 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -20,6 +20,7 @@ #include <vespa/searchcommon/common/schemaconfigurer.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> using namespace config; using namespace proton; @@ -71,12 +72,15 @@ struct DBConfigFixture { const vespalib::string &configId, const vespalib::string &docTypeName) { + AttributeSpecsBuilder attributeSpecsBuilder; + attributeSpecsBuilder.setup(_attributesBuilder); return std::make_shared<DocumentDBConfig> (generation, std::make_shared<RankProfilesConfig>(_rankProfilesBuilder), buildRankingConstants(), std::make_shared<IndexschemaConfig>(_indexschemaBuilder), - std::make_shared<AttributesConfig>(_attributesBuilder), + attributeSpecsBuilder.getAttributesConfig(), + attributeSpecsBuilder.getAttributeSpecs(), std::make_shared<SummaryConfig>(_summaryBuilder), std::make_shared<SummarymapConfig>(_summarymapBuilder), std::make_shared<JuniperrcConfig>(_juniperrcBuilder), diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.cpp index 81b4cc54062..504dfa9f102 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/config-indexschema.h> #include <vespa/config-attributes.h> +#include "attribute_specs.h" using search::attribute::ConfigConverter; using vespa::config::search::AttributesConfig; @@ -68,7 +69,7 @@ bool willTriggerReprocessOnAttributeAspectRemoval(const search::attribute::Confi } AttributeSpecsBuilder::AttributeSpecsBuilder() - : _specs(), + : _specs(std::make_shared<AttributeSpecs>()), _config(std::make_shared<AttributesConfigBuilder>()) { } @@ -77,7 +78,7 @@ AttributeSpecsBuilder::~AttributeSpecsBuilder() { } -const AttributeSpecs & +std::shared_ptr<const AttributeSpecs> AttributeSpecsBuilder::getAttributeSpecs() const { return _specs; @@ -94,7 +95,7 @@ AttributeSpecsBuilder::setup(const AttributesConfig &newConfig) { for (const auto &attr : newConfig.attribute) { search::attribute::Config cfg = ConfigConverter::convert(attr); - _specs.emplace_back(attr.name, cfg); + _specs->emplace_back(attr.name, cfg); } _config = std::make_shared<AttributesConfigBuilder>(newConfig); } @@ -181,9 +182,9 @@ AttributeSpecsBuilder::setup(const AttributesConfig &oldAttributesConfig, { IndexConfigHash oldIndexes(oldIndexschemaConfig.indexfield); handleNewAttributes(oldAttributesConfig, newAttributesConfig, - oldIndexes, inspector, _specs, *_config); + oldIndexes, inspector, *_specs, *_config); handleOldAttributes(oldAttributesConfig, newAttributesConfig, - oldIndexes, inspector, _specs, *_config); + oldIndexes, inspector, *_specs, *_config); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.h index d5913e4403c..9f74d37afdd 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs_builder.h @@ -2,7 +2,7 @@ #pragma once -#include "attribute_specs.h" +#include <memory> namespace document { class DocumentType; } namespace vespa { namespace config { namespace search { namespace internal { @@ -13,6 +13,7 @@ class InternalIndexschemaType; namespace proton { class IDocumentTypeInspector; +class AttributeSpecs; /* * Class to build adjusted attribute config and vector of attribute specs @@ -25,7 +26,7 @@ class AttributeSpecsBuilder using DocumentType = document::DocumentType; using IndexschemaConfig = const vespa::config::search::internal::InternalIndexschemaType; - AttributeSpecs _specs; + std::shared_ptr<AttributeSpecs> _specs; std::shared_ptr<AttributesConfigBuilder> _config; public: @@ -46,7 +47,7 @@ public: const IndexschemaConfig &oldIndexschemaConfig, const IDocumentTypeInspector &inspector); - const AttributeSpecs &getAttributeSpecs() const; + std::shared_ptr<const AttributeSpecs> getAttributeSpecs() const; std::shared_ptr<AttributesConfig> getAttributesConfig() const; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp index ce9fc592ff7..2633931f223 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp @@ -9,6 +9,7 @@ #include <vespa/config-summarymap.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/document/config/config-documenttypes.h> +#include <vespa/searchcore/proton/attribute/attribute_specs.h> using namespace config; using namespace vespa::config::search::summary; @@ -45,6 +46,7 @@ DocumentDBConfig::DocumentDBConfig( const RankingConstants::SP &rankingConstants, const IndexschemaConfigSP &indexschema, const AttributesConfigSP &attributes, + const std::shared_ptr<const AttributeSpecs> &attributeSpecs, const SummaryConfigSP &summary, const SummarymapConfigSP &summarymap, const JuniperrcConfigSP &juniperrc, @@ -64,6 +66,7 @@ DocumentDBConfig::DocumentDBConfig( _rankingConstants(rankingConstants), _indexschema(indexschema), _attributes(attributes), + _attributeSpecs(attributeSpecs), _summary(summary), _summarymap(summarymap), _juniperrc(juniperrc), @@ -87,6 +90,7 @@ DocumentDBConfig(const DocumentDBConfig &cfg) _rankingConstants(cfg._rankingConstants), _indexschema(cfg._indexschema), _attributes(cfg._attributes), + _attributeSpecs(cfg._attributeSpecs), _summary(cfg._summary), _summarymap(cfg._summarymap), _juniperrc(cfg._juniperrc), @@ -113,6 +117,8 @@ DocumentDBConfig::operator==(const DocumentDBConfig & rhs) const rhs._indexschema.get()) && equals<AttributesConfig>(_attributes.get(), rhs._attributes.get()) && + equals<AttributeSpecs>(_attributeSpecs.get(), + rhs._attributeSpecs.get()) && equals<SummaryConfig>(_summary.get(), rhs._summary.get()) && equals<SummarymapConfig>(_summarymap.get(), @@ -144,7 +150,8 @@ DocumentDBConfig::compare(const DocumentDBConfig &rhs) const retval.indexschemaChanged = !equals<IndexschemaConfig>(_indexschema.get(), rhs._indexschema.get()); retval.attributesChanged = - !equals<AttributesConfig>(_attributes.get(), rhs._attributes.get()); + !equals<AttributesConfig>(_attributes.get(), rhs._attributes.get()) || + !equals<AttributeSpecs>(_attributeSpecs.get(), rhs._attributeSpecs.get()); retval.summaryChanged = !equals<SummaryConfig>(_summary.get(), rhs._summary.get()); retval.summarymapChanged = @@ -176,6 +183,7 @@ DocumentDBConfig::valid() const (_rankingConstants.get() != NULL) && (_indexschema.get() != NULL) && (_attributes.get() != NULL) && + _attributeSpecs && (_summary.get() != NULL) && (_summarymap.get() != NULL) && (_juniperrc.get() != NULL) && @@ -216,6 +224,7 @@ DocumentDBConfig::makeReplayConfig(const SP & orig) std::make_shared<RankingConstants>(), o._indexschema, o._attributes, + o._attributeSpecs, o._summary, o._summarymap, o._juniperrc, @@ -248,7 +257,8 @@ DocumentDBConfig::preferOriginalConfig(const SP & self) DocumentDBConfig::SP -DocumentDBConfig::newFromAttributesConfig(const AttributesConfigSP &attributes) const +DocumentDBConfig::newFromAttributesConfig(const AttributesConfigSP &attributes, + const std::shared_ptr<const AttributeSpecs> &attributeSpecs) const { return std::make_shared<DocumentDBConfig>( _generation, @@ -256,6 +266,7 @@ DocumentDBConfig::newFromAttributesConfig(const AttributesConfigSP &attributes) _rankingConstants, _indexschema, attributes, + attributeSpecs, _summary, _summarymap, _juniperrc, diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h index e37c0532740..51de714ee30 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h @@ -31,6 +31,8 @@ namespace document { namespace internal { class InternalDocumenttypesType; } } namespace proton { +class AttributeSpecs; + class DocumentDBConfig { public: @@ -82,6 +84,7 @@ private: RankingConstants::SP _rankingConstants; IndexschemaConfigSP _indexschema; AttributesConfigSP _attributes; + std::shared_ptr<const AttributeSpecs> _attributeSpecs; SummaryConfigSP _summary; SummarymapConfigSP _summarymap; JuniperrcConfigSP _juniperrc; @@ -109,6 +112,7 @@ public: const RankingConstants::SP &rankingConstants, const IndexschemaConfigSP &indexschema, const AttributesConfigSP &attributes, + const std::shared_ptr<const AttributeSpecs> &attributeSpecs, const SummaryConfigSP &summary, const SummarymapConfigSP &summarymap, const JuniperrcConfigSP &juniperrc, @@ -155,6 +159,9 @@ public: const search::index::Schema::SP &getSchemaSP() const { return _schema; } const MaintenanceConfigSP &getMaintenanceConfigSP() const { return _maintenance; } const search::TuneFileDocumentDB::SP &getTuneFileDocumentDBSP() const { return _tuneFileDocumentDB; } + const AttributeSpecs &getAttributeSpecs() const { return *_attributeSpecs; } + const std::shared_ptr<const AttributeSpecs> &getAttributeSpecsSP() const { return _attributeSpecs; } + bool operator==(const DocumentDBConfig &rhs) const; /** @@ -187,7 +194,8 @@ public: /** * Create modified attributes config. */ - SP newFromAttributesConfig(const AttributesConfigSP &attributes) const; + SP newFromAttributesConfig(const AttributesConfigSP &attributes, + const std::shared_ptr<const AttributeSpecs> &attributeSpecs) const; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index a258a282f81..0537f479fed 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -12,6 +12,7 @@ #include <vespa/searchlib/index/schemautil.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/vespalib/time/time_box.h> +#include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> LOG_SETUP(".proton.server.documentdbconfigmanager"); @@ -268,12 +269,15 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) newMaintenanceConfig = oldMaintenanceConfig; } ConfigSnapshot extraConfigs(snapshot.subset(_extraConfigKeys)); + AttributeSpecsBuilder attributeSpecsBuilder; + attributeSpecsBuilder.setup(*newAttributesConfig); DocumentDBConfig::SP newSnapshot( new DocumentDBConfig(generation, newRankProfilesConfig, newRankingConstants, newIndexschemaConfig, - newAttributesConfig, + attributeSpecsBuilder.getAttributesConfig(), + attributeSpecsBuilder.getAttributeSpecs(), newSummaryConfig, newSummarymapConfig, newJuniperrcConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp index 2ebadce7e38..d641802aea2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp @@ -3,6 +3,7 @@ #include <vespa/fastos/fastos.h> #include "documentdbconfigscout.h" #include <vespa/searchcore/proton/attribute/attributesconfigscout.h> +#include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> using vespa::config::search::AttributesConfig; @@ -19,7 +20,10 @@ DocumentDBConfigScout::scout(const DocumentDBConfig::SP &config, ac(acScout.adjust(config->getAttributesConfig())); if (*ac == config->getAttributesConfig()) return config; // no change - return config->newFromAttributesConfig(ac); + AttributeSpecsBuilder attributeSpecsBuilder; + attributeSpecsBuilder.setup(*ac); + return config->newFromAttributesConfig(attributeSpecsBuilder.getAttributesConfig(), + attributeSpecsBuilder.getAttributeSpecs()); } 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 14ed502cdc1..62e3c55903d 100644 --- a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp +++ b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp @@ -9,6 +9,7 @@ #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/config-imported-fields.h> +#include <vespa/searchcore/proton/attribute/attribute_specs_builder.h> using document::DocumenttypesConfig; using search::TuneFileDocumentDB; @@ -73,12 +74,15 @@ DocumentDBConfigBuilder::DocumentDBConfigBuilder(const DocumentDBConfig &cfg) DocumentDBConfig::SP DocumentDBConfigBuilder::build() { + AttributeSpecsBuilder attributeSpecsBuilder; + attributeSpecsBuilder.setup(*_attributes); return std::make_shared<DocumentDBConfig>( _generation, _rankProfiles, _rankingConstants, _indexschema, - _attributes, + attributeSpecsBuilder.getAttributesConfig(), + attributeSpecsBuilder.getAttributeSpecs(), _summary, _summarymap, _juniperrc, |