diff options
author | Geir Storli <geirst@yahoo-inc.com> | 2017-08-14 14:28:18 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahoo-inc.com> | 2017-08-16 10:55:00 +0200 |
commit | 64383fa4fdff3d52cb9c7a1838f7b9cdb14be960 (patch) | |
tree | 3fac0d48b00510cd4490e0c2e7a10dcf9c4e7b19 /searchcore | |
parent | b4cfba33ec44fa66483f1a00373073437c12ec6f (diff) |
Filter away imported attribute fields after building schema and before building document db config.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp | 9 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp | 22 |
2 files changed, 29 insertions, 2 deletions
diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index fb37fa7916a..99d5090ed0d 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -240,17 +240,24 @@ TEST_FF("require that documentdb config manager subscribes for config", ASSERT_TRUE(f1.configEqual("typea", getDocumentDBConfig(f1, f2))); } -TEST_FF("require that documentdb config manager builds schema with imported attribute fields", +TEST_FF("require that documentdb config manager builds config with imported attribute fields", ConfigTestFixture("search"), DocumentDBConfigManager(f1.configId + "/typea", "typea")) { auto *docType = f1.addDocType("typea"); docType->importedFieldsBuilder.attribute.resize(1); docType->importedFieldsBuilder.attribute[0].name = "imported"; + docType->attributesBuilder.attribute.resize(2); + docType->attributesBuilder.attribute[0].name = "imported"; + docType->attributesBuilder.attribute[0].imported = true; + docType->attributesBuilder.attribute[1].name = "regular"; const auto &schema = getDocumentDBConfig(f1, f2)->getSchemaSP(); EXPECT_EQUAL(1u, schema->getNumImportedAttributeFields()); EXPECT_EQUAL("imported", schema->getImportedAttributeFields()[0].getName()); + const auto &attrCfg = getDocumentDBConfig(f1, f2)->getAttributesConfig(); + EXPECT_EQUAL(1u, attrCfg.attribute.size()); + EXPECT_EQUAL("regular", attrCfg.attribute[0].name); } TEST_FFF("require that proton config fetcher follows changes to bootstrap", diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index 3bcc9ce8ac2..950802ed394 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -138,6 +138,26 @@ buildMaintenanceConfig(const BootstrapConfig::SP &bootstrapConfig, proton.maintenancejobs.maxoutstandingmoveops)); } +namespace { + +using AttributesConfigSP = DocumentDBConfig::AttributesConfigSP; +using AttributesConfigBuilder = vespa::config::search::AttributesConfigBuilder; +using AttributesConfigBuilderSP = std::shared_ptr<AttributesConfigBuilder>; + +AttributesConfigSP +filterImportedAttributes(const AttributesConfigSP &attrCfg) +{ + AttributesConfigBuilderSP result = std::make_shared<AttributesConfigBuilder>(); + result->attribute.reserve(attrCfg->attribute.size()); + for (const auto &attr : attrCfg->attribute) { + if (!attr.imported) { + result->attribute.push_back(attr); + } + } + return result; +} + +} void DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) @@ -274,7 +294,7 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) newRankProfilesConfig, newRankingConstants, newIndexschemaConfig, - newAttributesConfig, + filterImportedAttributes(newAttributesConfig), newSummaryConfig, newSummarymapConfig, newJuniperrcConfig, |