diff options
Diffstat (limited to 'searchcore/src/vespa/searchcore/proton/attribute')
5 files changed, 34 insertions, 0 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index 4b6e67212e1..032be9e1dc8 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -575,6 +575,21 @@ AttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> { for (const auto &attr : _attributes) { if (attr.second.isExtra()) { + // We must skip extra attributes as they must be handled in other threads. (DocumentMetaStore) + continue; + } + AttributeVector::SP attrsp = attr.second.getAttribute(); + _attributeFieldWriter.execute(_attributeFieldWriter.getExecutorIdFromName(attrsp->getNamePrefix()), + [attrsp, func]() { (*func)(*attrsp); }); + } +} + +void +AttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const +{ + for (const auto &attr : _attributes) { + if (attr.second.isExtra()) { + // We must skip extra attributes as they must be handled in other threads.(DocumentMetaStore) continue; } AttributeVector::SP attrsp = attr.second.getAttribute(); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h index 64f0418c299..e2b9550435d 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h @@ -178,6 +178,7 @@ public: const std::vector<search::AttributeVector *> &getWritableAttributes() const override; void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override; + void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> 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 07bc1c638b5..c7ab83ae590 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp @@ -206,6 +206,22 @@ FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFun } void +FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const +{ + // Run by document db master thread + std::vector<AttributeGuard> completeList; + _mgr->getAttributeList(completeList); + vespalib::ISequencedTaskExecutor &attributeFieldWriter = getAttributeFieldWriter(); + for (auto &guard : completeList) { + search::AttributeVector::SP attrsp = guard.getSP(); + // Name must be extracted in document db master thread or attribute + // writer thread + attributeFieldWriter.execute(attributeFieldWriter.getExecutorIdFromName(attrsp->getNamePrefix()), + [attrsp, func]() { (*func)(*attrsp); }); + } +} + +void FilterAttributeManager::asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const { AttributeGuard::UP attr = _mgr->getAttribute(name); if (!attr) { return; } 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 9d09aef8faf..1ae5f452218 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h @@ -52,6 +52,7 @@ public: search::AttributeVector * getWritableAttribute(const vespalib::string &name) const override; const std::vector<search::AttributeVector *> & getWritableAttributes() const override; void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override; + void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> 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 65796fd4c74..d55cd45d014 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h @@ -98,6 +98,7 @@ struct IAttributeManager : public search::IAttributeManager virtual const std::vector<search::AttributeVector *> &getWritableAttributes() const = 0; virtual void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const = 0; + virtual void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const = 0; virtual ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const = 0; |