diff options
author | Henning Baldersheim <balder@oath.com> | 2018-08-29 00:34:08 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-08-29 00:34:08 +0200 |
commit | 72300dc30237f4f10432652e4e9da45a5563db30 (patch) | |
tree | 293cc0148bf84656d19190450d08fa9a264b73a0 /searchcore | |
parent | 9ae2e92efcfa3a95a6bd988dc7e34d7c84350289 (diff) |
Expose constness in interface to avoid cheating.
Diffstat (limited to 'searchcore')
8 files changed, 11 insertions, 14 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 b0bf905ba75..b390edfda88 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 @@ -79,7 +79,7 @@ namespace { const uint64_t createSerialNum = 42u; -class MyAttributeFunctor : public search::attribute::IAttributeFunctor +class MyAttributeFunctor : public search::attribute::IConstAttributeFunctor { std::vector<vespalib::string> _names; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h index 12461af0d27..93746165a24 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h @@ -13,7 +13,7 @@ class AttributeUsageSamplerContext; * Functor for sampling attribute usage and passing it on to sampler * context. */ -class AttributeUsageSamplerFunctor : public search::attribute::IAttributeFunctor +class AttributeUsageSamplerFunctor : public search::attribute::IConstAttributeFunctor { std::shared_ptr<AttributeUsageSamplerContext> _samplerContext; std::string _subDbName; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index 176c9e67608..be4be9392c5 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -573,7 +573,7 @@ AttributeManager::getWritableAttributes() const void -AttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const +AttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const { for (const auto &attr : _attributes) { if (attr.second.isExtra()) { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h index 9690fdcbdfe..cf60a0a41e9 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h @@ -170,7 +170,7 @@ public: const std::vector<search::AttributeVector *> &getWritableAttributes() const override; - void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const override; + void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override; void asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const override; ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const override; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp index 47a11b1c98d..fd1f95e13ba 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp @@ -185,7 +185,7 @@ FilterAttributeManager::getWritableAttributes() const } void -FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const +FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const { // Run by document db master thread std::vector<AttributeGuard> completeList; @@ -208,7 +208,7 @@ FilterAttributeManager::asyncForAttribute(const vespalib::string &name, std::uni vespalib::string attrName = (*attr)->getNamePrefix(); attributeFieldWriter.execute(attributeFieldWriter.getExecutorId(attrName), [attr=std::move(attr), func=std::move(func)]() mutable { - (*func)(dynamic_cast<const search::AttributeVector&>(**attr)); + (*func)(**attr); }); } @@ -216,11 +216,7 @@ FilterAttributeManager::asyncForAttribute(const vespalib::string &name, std::uni ExclusiveAttributeReadAccessor::UP FilterAttributeManager::getExclusiveReadAccessor(const vespalib::string &name) const { - if (acceptAttribute(name)) { - return _mgr->getExclusiveReadAccessor(name); - } else { - return ExclusiveAttributeReadAccessor::UP(); - } + return (acceptAttribute(name)) ? _mgr->getExclusiveReadAccessor(name) : ExclusiveAttributeReadAccessor::UP(); } void diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h index 12e88157075..099bb2e84ba 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h @@ -50,7 +50,7 @@ public: search::AttributeVector * getWritableAttribute(const vespalib::string &name) const override; const std::vector<search::AttributeVector *> & getWritableAttributes() const override; - void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const override; + void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override; ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const override; void setImportedAttributes(std::unique_ptr<ImportedAttributesRepo> attributes) override; const ImportedAttributesRepo *getImportedAttributes() const override; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h index 5df8cf0d0bf..4e50c52c58b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h @@ -31,6 +31,7 @@ struct IAttributeManager : public search::IAttributeManager using SP = std::shared_ptr<IAttributeManager>; using OnWriteDoneType = const std::shared_ptr<search::IDestructorCallback> &; using IAttributeFunctor = search::attribute::IAttributeFunctor; + using IConstAttributeFunctor = search::attribute::IConstAttributeFunctor; /** * Create a new attribute manager based on the content of the current one and @@ -92,7 +93,7 @@ struct IAttributeManager : public search::IAttributeManager */ virtual const std::vector<search::AttributeVector *> &getWritableAttributes() const = 0; - virtual void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const = 0; + virtual void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const = 0; virtual ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const = 0; diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h index e37fed4a9c6..87fa2053508 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h @@ -64,7 +64,7 @@ public: const std::vector<search::AttributeVector *> &getWritableAttributes() const override { HDR_ABORT("should not be reached"); } - void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor>) const override { + void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor>) const override { } ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &) const override { return ExclusiveAttributeReadAccessor::UP(); |