diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-04-20 12:40:25 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-04-20 12:40:25 +0000 |
commit | 6c5b85b120444fe013bc9ce93a6e88eb705ffdbd (patch) | |
tree | 18e2f695fc78643e774eeb23d85604d018cbf9ad /searchcore/src | |
parent | d509b1c0892133074105a10924f5bf7e61eb2583 (diff) |
Stop making attribute specs in AttributeAspectDelayer.
Diffstat (limited to 'searchcore/src')
4 files changed, 6 insertions, 123 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp index 7d5153e31cf..d935019be41 100644 --- a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp @@ -4,7 +4,6 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/searchcore/proton/test/attribute_utils.h> #include <vespa/searchcore/proton/attribute/attribute_aspect_delayer.h> -#include <vespa/searchcore/proton/attribute/attribute_specs.h> #include <vespa/searchcore/proton/common/i_document_type_inspector.h> #include <vespa/searchcore/proton/common/indexschema_inspector.h> #include <vespa/vespalib/test/insertion_operators.h> @@ -22,34 +21,9 @@ using search::attribute::Config; using search::attribute::BasicType; using search::attribute::CollectionType; -namespace { - -const char *boolStr(bool val) { - return val ? "true" : "false"; -} - -} - namespace std { -ostream &operator<<(ostream &os, const Config &cfg) -{ - os << "{basicType=" << cfg.basicType().asString(); - os << ", collectionType=" << cfg.collectionType().asString(); - os << ", fastAccess=" << boolStr(cfg.fastAccess()); - os << "}"; - return os; -} - -ostream &operator<<(ostream &os, const proton::AttributeSpec &spec) -{ - os << "{name=" << spec.getName(); - os << ", " << spec.getConfig(); - os << "}"; - return os; -} - ostream &operator<<(ostream &os, const SummarymapConfig::Override &override) { os << "{field=" << override.field << ", command=" << override.command << ", arguments=" << override.arguments << "}"; @@ -113,23 +87,6 @@ AttributesConfig::Attribute make_fa(const AttributesConfig::Attribute &cfg) return attr; } -Config make_fa(const Config &cfg) -{ - Config modCfg(cfg); - modCfg.setFastAccess(true); - return modCfg; -} - -const Config int32_sv(BasicType::Type::INT32); -const Config string_sv(BasicType::Type::STRING); - -Config getTensor(const vespalib::string &spec) -{ - Config ret(BasicType::Type::TENSOR); - ret.setTensorType(vespalib::eval::ValueType::from_spec(spec)); - return ret; -} - SummarymapConfig::Override make_attribute_override(const vespalib::string &name) { SummarymapConfig::Override override; @@ -207,11 +164,6 @@ public: newAttributesConfig, newSummarymapConfig, indexschemaInspector, _inspector); } - void assertSpecs(const std::vector<AttributeSpec> &expSpecs) - { - const auto &actSpecs = _delayer.getAttributeSpecs(); - EXPECT_EQUAL(expSpecs, actSpecs->getSpecs()); - } void assertAttributeConfig(const std::vector<AttributesConfig::Attribute> &exp) { auto actConfig = _delayer.getAttributesConfig(); @@ -224,17 +176,15 @@ public: } }; -TEST_F("require that empty specs is OK", Fixture) +TEST_F("require that empty config is OK", Fixture) { f.setup(attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); } -TEST_F("require that simple attribute specs is OK", Fixture) +TEST_F("require that simple attribute config is OK", Fixture) { f.setup(attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", int32_sv)})); TEST_DO(f.assertAttributeConfig({make_int32_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -243,7 +193,6 @@ TEST_F("require that adding attribute aspect is delayed if field type is unchang { f.addFields({"a"}); f.setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -252,7 +201,6 @@ TEST_F("require that adding attribute aspect is delayed if field type is unchang { f.addFields({"a"}); f.setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg()}), smCfg({make_geopos_override("a")})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({make_geopos_override("a")})); } @@ -260,7 +208,6 @@ TEST_F("require that adding attribute aspect is delayed if field type is unchang TEST_F("require that adding attribute is not delayed if field type changed", Fixture) { f.setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", int32_sv)})); TEST_DO(f.assertAttributeConfig({make_int32_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -269,7 +216,6 @@ TEST_F("require that removing attribute aspect is delayed if field type is uncha { f.addFields({"a"}); f.setup(attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({AttributeSpec("a", int32_sv)})); TEST_DO(f.assertAttributeConfig({make_int32_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -278,7 +224,6 @@ TEST_F("require that removing attribute aspect is delayed if field type is uncha { f.addFields({"a"}); f.setup(attrCfg({make_int32_sv_cfg()}), smCfg({make_geopos_override("a")}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({AttributeSpec("a", int32_sv)})); TEST_DO(f.assertAttributeConfig({make_int32_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({})); } @@ -286,7 +231,6 @@ TEST_F("require that removing attribute aspect is delayed if field type is uncha TEST_F("require that removing attribute aspect is not delayed if field type changed", Fixture) { f.setup(attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -296,7 +240,6 @@ TEST_F("require that removing attribute aspect is not delayed if also indexed", f.addFields({"a"}); f.addOldIndexField("a"); f.setup(attrCfg({make_string_sv_cfg()}), smCfg({make_attribute_override("a")}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -305,7 +248,6 @@ TEST_F("require that removing attribute aspect is not delayed for tensor", Fixtu { f.addFields({"a"}); f.setup(attrCfg({make_tensor_cfg("tensor(x[10])")}), smCfg({make_attribute_override("a")}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -314,7 +256,6 @@ TEST_F("require that removing attribute aspect is not delayed for predicate", Fi { f.addFields({"a"}); f.setup(attrCfg({make_predicate_cfg(4)}), smCfg({}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -323,7 +264,6 @@ TEST_F("require that removing attribute aspect is not delayed for reference", Fi { f.addFields({"a"}); f.setup(attrCfg({make_reference_cfg()}), smCfg({}), attrCfg({}), smCfg({})); - TEST_DO(f.assertSpecs({})); TEST_DO(f.assertAttributeConfig({})); TEST_DO(f.assertSummarymapConfig({})); } @@ -332,7 +272,6 @@ TEST_F("require that fast access flag change is delayed, false->true edge", Fixt { f.addFields({"a"}); f.setup(attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")}), attrCfg({make_fa(make_int32_sv_cfg())}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", int32_sv)})); TEST_DO(f.assertAttributeConfig({make_int32_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -341,7 +280,6 @@ TEST_F("require that fast access flag change is delayed, true->false edge", Fixt { f.addFields({"a"}); f.setup(attrCfg({make_fa(make_int32_sv_cfg())}), smCfg({make_attribute_override("a")}), attrCfg({make_int32_sv_cfg()}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", make_fa(int32_sv))})); TEST_DO(f.assertAttributeConfig({make_fa(make_int32_sv_cfg())})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -350,7 +288,6 @@ TEST_F("require that fast access flag change is delayed, false->true edge, tenso { f.addFields({"a"}); f.setup(attrCfg({make_tensor_cfg("tensor(x[10])")}), smCfg({make_attribute_override("a")}), attrCfg({make_fa(make_tensor_cfg("tensor(x[10])"))}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", getTensor("tensor(x[10])"))})); TEST_DO(f.assertAttributeConfig({make_tensor_cfg("tensor(x[10])")})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -359,7 +296,6 @@ TEST_F("require that fast access flag change is not delayed, true->false edge, t { f.addFields({"a"}); f.setup(attrCfg({make_fa(make_tensor_cfg("tensor(x[10])"))}), smCfg({make_attribute_override("a")}), attrCfg({make_tensor_cfg("tensor(x[10])")}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", getTensor("tensor(x[10])"))})); TEST_DO(f.assertAttributeConfig({make_tensor_cfg("tensor(x[10])")})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } @@ -369,7 +305,6 @@ TEST_F("require that fast access flag change is not delayed, true->false edge, s f.addFields({"a"}); f.addOldIndexField("a"); f.setup(attrCfg({make_fa(make_string_sv_cfg())}), smCfg({make_attribute_override("a")}), attrCfg({make_string_sv_cfg()}), smCfg({make_attribute_override("a")})); - TEST_DO(f.assertSpecs({AttributeSpec("a", string_sv)})); TEST_DO(f.assertAttributeConfig({make_string_sv_cfg()})); TEST_DO(f.assertSummarymapConfig({make_attribute_override("a")})); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp index 4edfdbdd355..d0f511c3bdb 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp @@ -8,7 +8,6 @@ #include <vespa/vespalib/stllike/hash_set.hpp> #include <vespa/config-attributes.h> #include <vespa/config-summarymap.h> -#include "attribute_specs.h" using search::attribute::ConfigConverter; using vespa::config::search::AttributesConfig; @@ -41,8 +40,7 @@ bool willTriggerReprocessOnAttributeAspectRemoval(const search::attribute::Confi } AttributeAspectDelayer::AttributeAspectDelayer() - : _specs(std::make_shared<AttributeSpecs>()), - _attributesConfig(std::make_shared<AttributesConfigBuilder>()), + : _attributesConfig(std::make_shared<AttributesConfigBuilder>()), _summarymapConfig(std::make_shared<SummarymapConfigBuilder>()) { } @@ -51,12 +49,6 @@ AttributeAspectDelayer::~AttributeAspectDelayer() { } -std::shared_ptr<const AttributeSpecs> -AttributeAspectDelayer::getAttributeSpecs() const -{ - return _specs; -} - std::shared_ptr<AttributeAspectDelayer::AttributesConfig> AttributeAspectDelayer::getAttributesConfig() const { @@ -72,10 +64,6 @@ AttributeAspectDelayer::getSummarymapConfig() const void AttributeAspectDelayer::setup(const AttributesConfig &newAttributesConfig, const SummarymapConfig &newSummarymapConfig) { - for (const auto &attr : newAttributesConfig.attribute) { - search::attribute::Config cfg = ConfigConverter::convert(attr); - _specs->emplace_back(attr.name, cfg); - } _attributesConfig = std::make_shared<AttributesConfigBuilder>(newAttributesConfig); _summarymapConfig = std::make_shared<SummarymapConfigBuilder>(newSummarymapConfig); } @@ -88,7 +76,6 @@ handleNewAttributes(const AttributesConfig &oldAttributesConfig, const SummarymapConfig &newSummarymapConfig, const IIndexschemaInspector &oldIndexschemaInspector, const IDocumentTypeInspector &inspector, - AttributeSpecs &specs, AttributesConfigBuilder &attributesConfig, SummarymapConfigBuilder &summarymapConfig) { @@ -98,7 +85,6 @@ handleNewAttributes(const AttributesConfig &oldAttributesConfig, search::attribute::Config newCfg = ConfigConverter::convert(newAttr); if (!inspector.hasUnchangedField(newAttr.name)) { // No reprocessing due to field type change, just use new config - specs.emplace_back(newAttr.name, newCfg); attributesConfig.attribute.emplace_back(newAttr); } else { auto oldAttr = oldAttrs.lookup(newAttr.name); @@ -107,7 +93,6 @@ handleNewAttributes(const AttributesConfig &oldAttributesConfig, if (willTriggerReprocessOnAttributeAspectRemoval(oldCfg, oldIndexschemaInspector, newAttr.name) || !oldAttr->fastaccess) { // Delay change of fast access flag newCfg.setFastAccess(oldAttr->fastaccess); - specs.emplace_back(newAttr.name, newCfg); auto modNewAttr = newAttr; modNewAttr.fastaccess = oldAttr->fastaccess; attributesConfig.attribute.emplace_back(modNewAttr); @@ -119,7 +104,6 @@ handleNewAttributes(const AttributesConfig &oldAttributesConfig, // Don't delay change of fast access flag from true to // false when removing attribute aspect in a way that // doesn't trigger reprocessing. - specs.emplace_back(newAttr.name, newCfg); attributesConfig.attribute.emplace_back(newAttr); } } else { @@ -146,7 +130,6 @@ handleOldAttributes(const AttributesConfig &oldAttributesConfig, const SummarymapConfig &oldSummarymapConfig, const IIndexschemaInspector &oldIndexschemaInspector, const IDocumentTypeInspector &inspector, - AttributeSpecs &specs, AttributesConfigBuilder &attributesConfig, SummarymapConfigBuilder &summarymapConfig) { @@ -160,7 +143,6 @@ handleOldAttributes(const AttributesConfig &oldAttributesConfig, // Delay removal of attribute aspect if it would trigger // reprocessing. if (willTriggerReprocessOnAttributeAspectRemoval(oldCfg, oldIndexschemaInspector, oldAttr.name)) { - specs.emplace_back(oldAttr.name, oldCfg); attributesConfig.attribute.emplace_back(oldAttr); delayed.insert(oldAttr.name); } @@ -189,11 +171,11 @@ AttributeAspectDelayer::setup(const AttributesConfig &oldAttributesConfig, { handleNewAttributes(oldAttributesConfig, newAttributesConfig, newSummarymapConfig, - oldIndexschemaInspector, inspector, *_specs, + oldIndexschemaInspector, inspector, *_attributesConfig, *_summarymapConfig); handleOldAttributes(oldAttributesConfig, newAttributesConfig, oldSummarymapConfig, - oldIndexschemaInspector, inspector, *_specs, + oldIndexschemaInspector, inspector, *_attributesConfig, *_summarymapConfig); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.h index df4ab16c3ef..6ed54908025 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.h @@ -15,10 +15,9 @@ namespace proton { class IDocumentTypeInspector; class IIndexschemaInspector; -class AttributeSpecs; /* - * Class to build adjusted attribute config and vector of attribute specs + * Class to build adjusted attributes config and summary map config * to eliminate need for reprocessing when system is online. */ class AttributeAspectDelayer @@ -30,7 +29,6 @@ class AttributeAspectDelayer using SummarymapConfigBuilder = vespa::config::search::internal::InternalSummarymapType; using SummarymapConfig = const vespa::config::search::internal::InternalSummarymapType; - std::shared_ptr<AttributeSpecs> _specs; std::shared_ptr<AttributesConfigBuilder> _attributesConfig; std::shared_ptr<SummarymapConfigBuilder> _summarymapConfig; @@ -54,7 +52,6 @@ public: const IIndexschemaInspector &oldIndexschemaInspector, const IDocumentTypeInspector &inspector); - std::shared_ptr<const AttributeSpecs> getAttributeSpecs() const; std::shared_ptr<AttributesConfig> getAttributesConfig() const; std::shared_ptr<SummarymapConfig> getSummarymapConfig() const; }; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs.h deleted file mode 100644 index 7c231b4f917..00000000000 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_specs.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "attribute_spec.h" -#include <vector> - -namespace proton { - -/** - * A specification of attribute vectors an attribute manager should - * instantiate and manage. - */ -class AttributeSpecs -{ -private: - std::vector<AttributeSpec> _specs; -public: - AttributeSpecs() - : _specs() - { - } - ~AttributeSpecs() { } - const std::vector<AttributeSpec> &getSpecs() const { return _specs; } - bool operator==(const AttributeSpecs &rhs) const { return _specs == rhs._specs; } - template <typename ...Args> - void emplace_back(Args && ... args) { _specs.emplace_back(std::forward<Args>(args)...); } -}; - -} // namespace proton - |