diff options
author | Tor Egge <Tor.Egge@oath.com> | 2018-04-23 13:38:48 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-04-23 13:53:39 +0000 |
commit | 6aa64a88856f769332476f16610812c004478ff8 (patch) | |
tree | 7db48103c3719f2e69cdc7b03ee202b4715b89c7 /searchcore/src | |
parent | a4417a32a4e048bbdb2e347307f93de5bca865e1 (diff) |
Add shared pointer to document meta store context for referenced
document type to imported attribute vector.
Diffstat (limited to 'searchcore/src')
10 files changed, 26 insertions, 7 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 59393ac0a26..0c38c645b07 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 @@ -139,7 +139,8 @@ struct ImportedAttributesRepoBuilder { refAttr->setGidToLidMapperFactory(std::make_shared<MockGidToLidMapperFactory>()); auto targetAttr = search::AttributeFactory::createAttribute(name + "_target", INT32_SINGLE); auto documentMetaStore = std::shared_ptr<search::IDocumentMetaStoreContext>(); - auto importedAttr = ImportedAttributeVectorFactory::create(name, refAttr, targetAttr, documentMetaStore, false); + auto targetDocumentMetaStore = std::shared_ptr<const search::IDocumentMetaStoreContext>(); + auto importedAttr = ImportedAttributeVectorFactory::create(name, refAttr, documentMetaStore, targetAttr, targetDocumentMetaStore, false); _repo->add(name, importedAttr); } ImportedAttributesRepo::UP build() { diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index 4a9d1b31c8e..ee5f29255fb 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -748,8 +748,9 @@ createImportedAttribute(const vespalib::string &name) { auto result = ImportedAttributeVectorFactory::create(name, std::shared_ptr<ReferenceAttribute>(), - AttributeVector::SP(), std::shared_ptr<search::IDocumentMetaStoreContext>(), + AttributeVector::SP(), + std::shared_ptr<const search::IDocumentMetaStoreContext>(), true); result->getSearchCache()->insert("foo", BitVectorSearchCache::Entry::SP()); return result; diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp index 998537b2745..9f074b89235 100644 --- a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp +++ b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp @@ -77,8 +77,9 @@ struct Fixture { Fixture &addAttribute(const vespalib::string &name) { auto attr = ImportedAttributeVectorFactory::create(name, createReferenceAttribute(name + "_ref"), - createTargetAttribute(name + "_target"), std::shared_ptr<search::IDocumentMetaStoreContext>(), + createTargetAttribute(name + "_target"), + std::shared_ptr<const search::IDocumentMetaStoreContext>(), false); repo.add(name, attr); return *this; diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp index ddabed210d8..d92392ec8df 100644 --- a/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp +++ b/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp @@ -23,8 +23,9 @@ createAttr(const vespalib::string &name) { return ImportedAttributeVectorFactory::create(name, ReferenceAttribute::SP(), - AttributeVector::SP(), std::shared_ptr<search::IDocumentMetaStoreContext>(), + AttributeVector::SP(), + std::shared_ptr<const search::IDocumentMetaStoreContext>(), false); } diff --git a/searchcore/src/tests/proton/reference/document_db_reference/document_db_reference_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference/document_db_reference_test.cpp index b600d6842bd..fc9d2d770cd 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference/document_db_reference_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference/document_db_reference_test.cpp @@ -26,8 +26,9 @@ makeImportedAttributesRepo() ImportedAttributesRepo::UP result = std::make_unique<ImportedAttributesRepo>(); ImportedAttributeVector::SP attr = std::make_shared<ImportedAttributeVector>("imported", std::shared_ptr<ReferenceAttribute>(), + std::shared_ptr<IDocumentMetaStoreContext>(), std::shared_ptr<ReadableAttributeVector>(), - std::shared_ptr<IDocumentMetaStoreContext>(), false); + std::shared_ptr<const IDocumentMetaStoreContext>(), false); result->add("imported", std::move(attr)); return result; } diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.cpp index cf8943595d2..61f534fe006 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.cpp @@ -39,6 +39,12 @@ DocumentDBReference::getAttribute(vespalib::stringref name) } } +std::shared_ptr<const search::IDocumentMetaStoreContext> +DocumentDBReference::getDocumentMetaStoreContext() const +{ + return _dmsContext; +} + std::shared_ptr<search::IGidToLidMapperFactory> DocumentDBReference::getGidToLidMapperFactory() { diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.h b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.h index 1d55342dbdc..52a06e52f1a 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.h +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference.h @@ -26,6 +26,7 @@ public: std::shared_ptr<IGidToLidChangeHandler> gidToLidChangeHandler); virtual ~DocumentDBReference(); virtual std::shared_ptr<search::attribute::ReadableAttributeVector> getAttribute(vespalib::stringref name) override; + virtual std::shared_ptr<const search::IDocumentMetaStoreContext> getDocumentMetaStoreContext() const override; virtual std::shared_ptr<search::IGidToLidMapperFactory> getGidToLidMapperFactory() override; virtual std::unique_ptr<GidToLidChangeRegistrator> makeGidToLidChangeRegistrator(const vespalib::string &docTypeName) override; }; diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp index 99b7eb300bf..cf6f0b99176 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp @@ -143,8 +143,10 @@ DocumentDBReferenceResolver::createImportedAttributesRepo(const IAttributeManage if (_useReferences) { for (const auto &attr : _importedFieldsCfg.attribute) { ReferenceAttribute::SP refAttr = getReferenceAttribute(attr.referencefield, attrMgr); - auto targetAttr = getTargetDocumentDB(refAttr->getName())->getAttribute(attr.targetfield); - auto importedAttr = ImportedAttributeVectorFactory::create(attr.name, refAttr, targetAttr, documentMetaStore, useSearchCache); + auto targetDocumentDB = getTargetDocumentDB(refAttr->getName()); + auto targetAttr = targetDocumentDB->getAttribute(attr.targetfield); + auto targetDocumentMetaStore = targetDocumentDB->getDocumentMetaStoreContext(); + auto importedAttr = ImportedAttributeVectorFactory::create(attr.name, refAttr, documentMetaStore, targetAttr, targetDocumentMetaStore, useSearchCache); result->add(importedAttr->getName(), importedAttr); } } diff --git a/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference.h b/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference.h index a37a553ed40..54f8009d1b8 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference.h +++ b/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference.h @@ -8,6 +8,7 @@ namespace search::attribute { class ReadableAttributeVector; } namespace search { class IGidToLidMapperFactory; +class IDocumentMetaStoreContext; } @@ -26,6 +27,7 @@ public: using SP = std::shared_ptr<IDocumentDBReference>; virtual ~IDocumentDBReference() { } virtual std::shared_ptr<search::attribute::ReadableAttributeVector> getAttribute(vespalib::stringref name) = 0; + virtual std::shared_ptr<const search::IDocumentMetaStoreContext> getDocumentMetaStoreContext() const = 0; virtual std::shared_ptr<search::IGidToLidMapperFactory> getGidToLidMapperFactory() = 0; virtual std::unique_ptr<GidToLidChangeRegistrator> makeGidToLidChangeRegistrator(const vespalib::string &docTypeName) = 0; }; diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_document_db_reference.h b/searchcore/src/vespa/searchcore/proton/test/mock_document_db_reference.h index defe78c0e75..cc91779faef 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_document_db_reference.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_document_db_reference.h @@ -18,6 +18,9 @@ struct MockDocumentDBReference : public IDocumentDBReference { virtual std::shared_ptr<search::attribute::ReadableAttributeVector> getAttribute(vespalib::stringref) override { return std::shared_ptr<search::attribute::ReadableAttributeVector>(); } + virtual std::shared_ptr<const search::IDocumentMetaStoreContext> getDocumentMetaStoreContext() const override { + return std::shared_ptr<const search::IDocumentMetaStoreContext>(); + } virtual std::shared_ptr<search::IGidToLidMapperFactory> getGidToLidMapperFactory() override { return std::shared_ptr<search::IGidToLidMapperFactory>(); } |