diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-03 21:56:23 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-03 21:56:23 +0000 |
commit | 5e683c18453928c7373f1fdadacd44f21518e47c (patch) | |
tree | f46054c8bd2bc0ad337adab885479f2439135459 | |
parent | 21e2f20a4f8b8299ddf01a5f337a8170934083de (diff) |
Let ImportedAttributesRepo return a reference to a shared_ptr instead of a shared_ptr since that is all you need.
7 files changed, 15 insertions, 18 deletions
diff --git a/eval/src/vespa/eval/instruction/generic_join.cpp b/eval/src/vespa/eval/instruction/generic_join.cpp index e1e02070466..60dc3e55143 100644 --- a/eval/src/vespa/eval/instruction/generic_join.cpp +++ b/eval/src/vespa/eval/instruction/generic_join.cpp @@ -36,7 +36,7 @@ generic_mixed_join(const Value &lhs, const Value &rhs, const JoinParam ¶m) SparseJoinState sparse(param.sparse_plan, lhs.index(), rhs.index()); size_t expected_subspaces = sparse.first_index.size(); if (param.sparse_plan.lhs_overlap.empty() && param.sparse_plan.rhs_overlap.empty()) { - expected_subspaces = sparse.first_index.size() * sparse.second_index.size(); + expected_subspaces = expected_subspaces * sparse.second_index.size(); } auto builder = param.factory.create_transient_value_builder<OCT>(param.res_type, param.sparse_plan.sources.size(), param.dense_plan.out_size, expected_subspaces); auto outer = sparse.first_index.create_view({}); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp index 0069a61b818..0aaa88db859 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp @@ -21,7 +21,7 @@ ImportedAttributesContext::getOrCacheAttribute(const vespalib::string &name, Att if (itr != attributes.end()) { return itr->second->attribute(); } - ImportedAttributeVector::SP result = _repo.get(name); + const ImportedAttributeVector::SP & result = _repo.get(name); if (result) { auto insRes = attributes.emplace(name, result->makeReadGuard(stableEnumGuard)); return insRes.first->second->attribute(); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp index fa10606299c..a45b327362a 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp @@ -8,15 +8,15 @@ namespace proton { using search::attribute::ImportedAttributeVector; -ImportedAttributesRepo::ImportedAttributesRepo() - : _repo() -{ -} +namespace { + +ImportedAttributeVector::SP _empty; -ImportedAttributesRepo::~ImportedAttributesRepo() -{ } +ImportedAttributesRepo::ImportedAttributesRepo() = default; +ImportedAttributesRepo::~ImportedAttributesRepo() = default; + void ImportedAttributesRepo::add(const vespalib::string &name, ImportedAttributeVector::SP attr) @@ -24,14 +24,14 @@ ImportedAttributesRepo::add(const vespalib::string &name, _repo[name] = std::move(attr); } -ImportedAttributeVector::SP +const ImportedAttributeVector::SP & ImportedAttributesRepo::get(const vespalib::string &name) const { auto itr = _repo.find(name); if (itr != _repo.end()) { return itr->second; } - return ImportedAttributeVector::SP(); + return _empty; } void diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h index 4e250b0ff5e..ff1e4bc5584 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h @@ -24,7 +24,7 @@ public: ImportedAttributesRepo(); ~ImportedAttributesRepo(); void add(const vespalib::string &name, std::shared_ptr<ImportedAttributeVector> attr); - std::shared_ptr<ImportedAttributeVector> get(const vespalib::string &name) const; + const std::shared_ptr<ImportedAttributeVector> & get(const vespalib::string &name) const; void getAll(std::vector<std::shared_ptr<ImportedAttributeVector>> &result) const; size_t size() const { return _repo.size(); } }; 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 5d1e1318b04..30708b757ab 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 @@ -145,8 +145,8 @@ DocumentDBReferenceResolver::createImportedAttributesRepo(const IAttributeManage ReferenceAttribute::SP refAttr = getReferenceAttribute(attr.referencefield, attrMgr); auto targetDocumentDB = getTargetDocumentDB(refAttr->getName()); auto targetAttr = targetDocumentDB->getAttribute(attr.targetfield); - auto targetDocumentMetaStore = targetDocumentDB->getDocumentMetaStore(); if (targetAttr) { + auto targetDocumentMetaStore = targetDocumentDB->getDocumentMetaStore(); auto importedAttr = ImportedAttributeVectorFactory::create(attr.name, refAttr, documentMetaStore, targetAttr, targetDocumentMetaStore, useSearchCache); result->add(importedAttr->getName(), importedAttr); } diff --git a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.cpp b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.cpp index 28e609c17ef..7520d7e81d2 100644 --- a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.cpp +++ b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.cpp @@ -2,7 +2,6 @@ #include "imported_tensor_attribute_vector.h" #include "imported_tensor_attribute_vector_read_guard.h" -#include <vespa/eval/eval/value.h> namespace search::tensor { @@ -34,9 +33,7 @@ ImportedTensorAttributeVector::ImportedTensorAttributeVector(vespalib::stringref { } -ImportedTensorAttributeVector::~ImportedTensorAttributeVector() -{ -} +ImportedTensorAttributeVector::~ImportedTensorAttributeVector() = default; std::unique_ptr<attribute::AttributeReadGuard> ImportedTensorAttributeVector::makeReadGuard(bool stableEnumGuard) const diff --git a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.h b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.h index d39a8395595..853b2b54beb 100644 --- a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.h +++ b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.h @@ -29,9 +29,9 @@ public: std::shared_ptr<attribute::ReadableAttributeVector> target_attribute, std::shared_ptr<const IDocumentMetaStoreContext> target_document_meta_store, std::shared_ptr<BitVectorSearchCache> search_cache); - ~ImportedTensorAttributeVector(); + ~ImportedTensorAttributeVector() override; - virtual std::unique_ptr<attribute::AttributeReadGuard> makeReadGuard(bool stableEnumGuard) const override; + std::unique_ptr<attribute::AttributeReadGuard> makeReadGuard(bool stableEnumGuard) const override; }; } |