diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-31 12:48:48 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-31 12:48:48 +0000 |
commit | 269b06c51dab99695f37fba3abbb173702479b7d (patch) | |
tree | ad7e6a8bc949b550b739fb4527e4ebab1044cb99 /searchcore | |
parent | b820e8a3056a069dd89036c4b4bbd078c87fac64 (diff) |
Move nested class AttributeCollectionSpec::Attribute out to AttributeSpec.
Diffstat (limited to 'searchcore')
8 files changed, 79 insertions, 61 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index a72e9862353..277f12e7485 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -64,7 +64,6 @@ using vespa::config::search::AttributesConfigBuilder; using vespalib::eval::ValueType; typedef search::attribute::Config AVConfig; -typedef proton::AttributeCollectionSpec::Attribute AttrSpec; typedef proton::AttributeCollectionSpec::AttributeList AttrSpecList; typedef proton::AttributeCollectionSpec AttrMgrSpec; @@ -415,9 +414,9 @@ TEST_F("require that reconfig can add attributes", Fixture) f._m.addExtraAttribute(ex); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a3", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a3", INT32_SINGLE)); SequentialAttributeManager sam(f._m, AttrMgrSpec(newSpec, f._m.getNumDocs(), 10)); std::vector<AttributeGuard> list; @@ -440,7 +439,7 @@ TEST_F("require that reconfig can remove attributes", Fixture) AttributeVector::SP a3 = f.addAttribute("a3"); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a2", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); SequentialAttributeManager sam(f._m, AttrMgrSpec(newSpec, 1, 10)); std::vector<AttributeGuard> list; @@ -461,9 +460,9 @@ TEST_F("require that new attributes after reconfig are initialized", Fixture) EXPECT_EQUAL(3u, a1->getNumDocs()); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a3", INT32_ARRAY)); + newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a3", INT32_ARRAY)); SequentialAttributeManager sam(f._m, AttrMgrSpec(newSpec, 3, 4)); AttributeGuard::UP a2ap = sam.mgr.getAttribute("a2"); @@ -501,7 +500,7 @@ TEST_F("require that removed attributes cannot resurrect", BaseFixture) am1.reset(); AttrSpecList ns2; - ns2.push_back(AttrSpec("a1", INT32_SINGLE)); + ns2.push_back(AttributeSpec("a1", INT32_SINGLE)); // 2 new documents added since a1 was removed SequentialAttributeManager am3(am2.mgr, AttrMgrSpec(ns2, 5, 20)); @@ -535,7 +534,7 @@ TEST_F("require that history can be wiped", Fixture) f._m.flushAll(10); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a2", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); SequentialAttributeManager sam(f._m, AttrMgrSpec(newSpec, 1, 11)); sam.mgr.wipeHistory(11); @@ -662,9 +661,9 @@ TEST_F("require that attributes can be initialized and loaded in sequence", Base AttributeManagerFixture amf(f); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a3", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a3", INT32_SINGLE)); SequentialAttributeManager newMgr(amf._m, AttrMgrSpec(newSpec, 10, createSerialNum + 5)); @@ -780,12 +779,12 @@ TEST_F("require that attribute vector of wrong type is dropped", BaseFixture) am1->addAttribute("a5", predicate, 5); am1->addAttribute("a6", predicate, 6); AttrSpecList newSpec; - newSpec.push_back(AttrSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttrSpec("a2", INT32_ARRAY)); - newSpec.push_back(AttrSpec("a3", generic_tensor)); - newSpec.push_back(AttrSpec("a4", dense_tensor)); - newSpec.push_back(AttrSpec("a5", predicate)); - newSpec.push_back(AttrSpec("a6", predicate2)); + newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); + newSpec.push_back(AttributeSpec("a2", INT32_ARRAY)); + newSpec.push_back(AttributeSpec("a3", generic_tensor)); + newSpec.push_back(AttributeSpec("a4", dense_tensor)); + newSpec.push_back(AttributeSpec("a5", predicate)); + newSpec.push_back(AttributeSpec("a6", predicate2)); SequentialAttributeManager am2(*am1, AttrMgrSpec(newSpec, 5, 20)); TEST_DO(assertCreateSerialNum(*am1, "a1", 1)); TEST_DO(assertCreateSerialNum(*am1, "a2", 2)); diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index 210b012c1f2..526358f65f5 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -60,9 +60,6 @@ using vespalib::tensor::TensorDimensions; typedef search::attribute::Config AVConfig; typedef search::attribute::BasicType AVBasicType; typedef search::attribute::CollectionType AVCollectionType; -typedef proton::AttributeCollectionSpec::Attribute AttrSpec; -typedef proton::AttributeCollectionSpec::AttributeList AttrSpecList; -typedef proton::AttributeCollectionSpec AttrMgrSpec; typedef SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> > Int32AttributeVector; namespace diff --git a/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt index 3972bd6dbc7..75d93d9e003 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt @@ -10,6 +10,7 @@ vespa_add_library(searchcore_attribute STATIC attribute_manager_explorer.cpp attribute_manager_initializer.cpp attribute_populator.cpp + attribute_spec.cpp attribute_usage_filter.cpp attribute_usage_sampler_context.cpp attribute_usage_sampler_functor.cpp diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp index aba6ab99ce1..0120e1c1630 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp @@ -4,25 +4,6 @@ namespace proton { -AttributeCollectionSpec::Attribute::Attribute(const vespalib::string &name, - const search::attribute::Config &cfg) - : _name(name), - _cfg(cfg) -{ -} - -AttributeCollectionSpec::Attribute::Attribute(const Attribute &) = default; - -AttributeCollectionSpec::Attribute & -AttributeCollectionSpec::Attribute::operator=(const Attribute &) = default; - -AttributeCollectionSpec::Attribute::Attribute(Attribute &&) = default; - -AttributeCollectionSpec::Attribute & -AttributeCollectionSpec::Attribute::operator=(Attribute &&) = default; - -AttributeCollectionSpec::Attribute::~Attribute() { } - AttributeCollectionSpec::AttributeCollectionSpec(const AttributeList &attributes, uint32_t docIdLimit, SerialNum currentSerialNum) diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h index ee5f913cb88..e447770562f 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/searchcommon/attribute/config.h> +#include "attribute_spec.h" #include <vespa/searchlib/common/serialnum.h> #include <memory> #include <vector> @@ -17,24 +17,7 @@ class AttributeCollectionSpec public: typedef std::unique_ptr<AttributeCollectionSpec> UP; - class Attribute - { - private: - vespalib::string _name; - search::attribute::Config _cfg; - public: - Attribute(const vespalib::string &name, - const search::attribute::Config &cfg); - Attribute(const Attribute &); - Attribute & operator=(const Attribute &); - Attribute(Attribute &&); - Attribute & operator=(Attribute &&); - ~Attribute(); - const vespalib::string &getName() const { return _name; } - const search::attribute::Config &getConfig() const { return _cfg; } - }; - - typedef std::vector<Attribute> AttributeList; + typedef std::vector<AttributeSpec> AttributeList; private: typedef search::SerialNum SerialNum; 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 8fc0b7128fd..b83680dc3f7 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 @@ -39,7 +39,7 @@ AttributeCollectionSpecFactory::create(const AttributesConfig &attrCfg, } grow.setDocsGrowDelta(grow.getDocsGrowDelta() + skew); cfg.setGrowStrategy(grow); - attrs.push_back(AttributeCollectionSpec::Attribute(attr.name, cfg)); + attrs.push_back(AttributeSpec(attr.name, cfg)); } return AttributeCollectionSpec::UP(new AttributeCollectionSpec(attrs, docIdLimit, diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp new file mode 100644 index 00000000000..b7031844199 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp @@ -0,0 +1,26 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "attribute_spec.h" + +namespace proton { + +AttributeSpec::AttributeSpec(const vespalib::string &name, + const search::attribute::Config &cfg) + : _name(name), + _cfg(cfg) +{ +} + +AttributeSpec::AttributeSpec(const AttributeSpec &) = default; + +AttributeSpec & +AttributeSpec::operator=(const AttributeSpec &) = default; + +AttributeSpec::AttributeSpec(AttributeSpec &&) = default; + +AttributeSpec & +AttributeSpec::operator=(AttributeSpec &&) = default; + +AttributeSpec::~AttributeSpec() { } + +} diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h new file mode 100644 index 00000000000..57dc5645cd1 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h @@ -0,0 +1,31 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/searchcommon/attribute/config.h> + +namespace proton { + +/** + * A specification of an attribute vector an attribute manager should + * instantiate and manage. + */ +class AttributeSpec +{ +private: + vespalib::string _name; + search::attribute::Config _cfg; +public: + AttributeSpec(const vespalib::string &name, + const search::attribute::Config &cfg); + AttributeSpec(const AttributeSpec &); + AttributeSpec & operator=(const AttributeSpec &); + AttributeSpec(AttributeSpec &&); + AttributeSpec & operator=(AttributeSpec &&); + ~AttributeSpec(); + const vespalib::string &getName() const { return _name; } + const search::attribute::Config &getConfig() const { return _cfg; } +}; + +} // namespace proton + |