summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-06-04 00:39:55 +0200
committerGitHub <noreply@github.com>2022-06-04 00:39:55 +0200
commit24a3487c20c02b450b9934f6d48431ec407678d5 (patch)
treef46054c8bd2bc0ad337adab885479f2439135459
parent21e2f20a4f8b8299ddf01a5f337a8170934083de (diff)
parent5e683c18453928c7373f1fdadacd44f21518e47c (diff)
Merge pull request #22910 from vespa-engine/balder/no-need-to-copy-shared-ptr
Let ImportedAttributesRepo return a reference to a shared_ptr instead…
-rw-r--r--eval/src/vespa/eval/instruction/generic_join.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector.h4
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 &param)
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;
};
}