aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-05-09 19:06:54 +0200
committerGitHub <noreply@github.com>2023-05-09 19:06:54 +0200
commitd141f17128adb53ea55d03aa78ac19cb9e90d4eb (patch)
tree5f47ed6a0658375eea7b46e16cf641ebab7f35a4 /searchlib
parent96f6dc86ab846429e41eec39170c6588ac62f1cb (diff)
parentb32f28cb625afed9f511a89b1ebfdcbb7e782dad (diff)
Merge pull request #27052 from vespa-engine/balder/use-shared-ptr-for-read-guard
Use shared_ptr for the read guard
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp2
-rw-r--r--searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp2
-rw-r--r--searchlib/src/tests/attribute/multi_value_read_view/multi_value_read_view_test.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.h2
-rw-r--r--searchlib/src/vespa/searchlib/common/i_document_meta_store_context.h4
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/irequestcontext.h4
-rw-r--r--searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h2
11 files changed, 20 insertions, 16 deletions
diff --git a/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp b/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
index 655460496d3..273cbeba13a 100644
--- a/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
@@ -14,7 +14,7 @@ using Entry = BitVectorSearchCache::Entry;
Entry::SP
makeEntry()
{
- return std::make_shared<Entry>(IDocumentMetaStoreContext::IReadGuard::UP(), BitVector::create(5), 10);
+ return std::make_shared<Entry>(IDocumentMetaStoreContext::IReadGuard::SP(), BitVector::create(5), 10);
}
struct Fixture {
diff --git a/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp b/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
index 19327245083..311d3ef71e7 100644
--- a/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
+++ b/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
@@ -474,7 +474,7 @@ makeSearchCacheEntry(const std::vector<uint32_t> docIds, uint32_t docIdLimit)
for (uint32_t docId : docIds) {
bitVector->setBit(docId);
}
- return std::make_shared<BitVectorSearchCache::Entry>(IDocumentMetaStoreContext::IReadGuard::UP(), bitVector, docIdLimit);
+ return std::make_shared<BitVectorSearchCache::Entry>(IDocumentMetaStoreContext::IReadGuard::SP(), bitVector, docIdLimit);
}
TEST_F("Bit vector from search cache is used if found", SearchCacheFixture)
diff --git a/searchlib/src/tests/attribute/multi_value_read_view/multi_value_read_view_test.cpp b/searchlib/src/tests/attribute/multi_value_read_view/multi_value_read_view_test.cpp
index 651f4458008..b5798bfdcc8 100644
--- a/searchlib/src/tests/attribute/multi_value_read_view/multi_value_read_view_test.cpp
+++ b/searchlib/src/tests/attribute/multi_value_read_view/multi_value_read_view_test.cpp
@@ -53,13 +53,13 @@ struct MockReadGuard : public IDocumentMetaStoreContext::IReadGuard {
struct MockDocumentMetaStoreContext : public IDocumentMetaStoreContext
{
- std::unique_ptr<IReadGuard> getReadGuard() const override;
+ std::shared_ptr<IReadGuard> getReadGuard() const override;
};
-std::unique_ptr<IDocumentMetaStoreContext::IReadGuard>
+std::shared_ptr<IDocumentMetaStoreContext::IReadGuard>
MockDocumentMetaStoreContext::getReadGuard() const
{
- return std::make_unique<MockReadGuard>();
+ return std::make_shared<MockReadGuard>();
}
diff --git a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
index d200002bd32..ba1baa2037e 100644
--- a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
+++ b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
@@ -19,16 +19,16 @@ namespace search::attribute {
class BitVectorSearchCache {
public:
using BitVectorSP = std::shared_ptr<BitVector>;
- using ReadGuardUP = IDocumentMetaStoreContext::IReadGuard::UP;
+ using ReadGuardSP = IDocumentMetaStoreContext::IReadGuard::SP;
struct Entry {
using SP = std::shared_ptr<Entry>;
// We need to keep a document meta store read guard to ensure that no lids that are cached
// in the bit vector are re-used until the guard is released.
- ReadGuardUP dmsReadGuard;
+ ReadGuardSP dmsReadGuard;
BitVectorSP bitVector;
uint32_t docIdLimit;
- Entry(ReadGuardUP dmsReadGuard_, BitVectorSP bitVector_, uint32_t docIdLimit_) noexcept
+ Entry(ReadGuardSP dmsReadGuard_, BitVectorSP bitVector_, uint32_t docIdLimit_) noexcept
: dmsReadGuard(std::move(dmsReadGuard_)), bitVector(std::move(bitVector_)), docIdLimit(docIdLimit_) {}
};
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
index 3d308b82b04..39a2a9f742c 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
@@ -38,7 +38,7 @@ ImportedSearchContext::ImportedSearchContext(
_searchCacheLookup((_useSearchCache ? _imported_attribute.getSearchCache()->find(_queryTerm) :
std::shared_ptr<BitVectorSearchCache::Entry>())),
_dmsReadGuard((_useSearchCache && !_searchCacheLookup) ? imported_attribute.getDocumentMetaStore()->getReadGuard() :
- std::unique_ptr<IDocumentMetaStoreContext::IReadGuard>()),
+ std::shared_ptr<IDocumentMetaStoreContext::IReadGuard>()),
_reference_attribute(*_imported_attribute.getReferenceAttribute()),
_target_attribute(target_attribute),
_target_search_context(_target_attribute.createSearchContext(std::move(term), params)),
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
index d6b6d09e8fc..8ac874edaf2 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
@@ -34,7 +34,7 @@ class ImportedSearchContext : public ISearchContext {
vespalib::string _queryTerm;
bool _useSearchCache;
BitVectorSearchCache::Entry::SP _searchCacheLookup;
- IDocumentMetaStoreContext::IReadGuard::UP _dmsReadGuard;
+ IDocumentMetaStoreContext::IReadGuard::SP _dmsReadGuard;
const ReferenceAttribute& _reference_attribute;
const IAttributeVector &_target_attribute;
std::unique_ptr<ISearchContext> _target_search_context;
diff --git a/searchlib/src/vespa/searchlib/common/i_document_meta_store_context.h b/searchlib/src/vespa/searchlib/common/i_document_meta_store_context.h
index bb0583972d4..93492427372 100644
--- a/searchlib/src/vespa/searchlib/common/i_document_meta_store_context.h
+++ b/searchlib/src/vespa/searchlib/common/i_document_meta_store_context.h
@@ -19,7 +19,7 @@ struct IDocumentMetaStoreContext {
*/
struct IReadGuard {
- using UP = std::unique_ptr<IReadGuard>;
+ using SP = std::shared_ptr<IReadGuard>;
virtual ~IReadGuard() {}
@@ -35,7 +35,7 @@ struct IDocumentMetaStoreContext {
* Access to read interface.
* Should be used by all reader threads.
*/
- virtual IReadGuard::UP getReadGuard() const = 0;
+ virtual IReadGuard::SP getReadGuard() const = 0;
};
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
index 0b727dcea42..4e9f149ccee 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
@@ -47,7 +47,7 @@ public:
}
const search::attribute::AttributeBlueprintParams& get_attribute_blueprint_params() const override;
-
+ const MetaStoreReadGuardSP * getMetaStoreReadGuard() const override { return nullptr; }
private:
std::unique_ptr<vespalib::TestClock> _clock;
const vespalib::Doom _doom;
diff --git a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
index 52992a52103..09f1dc51f60 100644
--- a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
@@ -3,6 +3,7 @@
#pragma once
#include <vespa/vespalib/stllike/string.h>
+#include <vespa/searchlib/common/i_document_meta_store_context.h>
namespace search::attribute { struct AttributeBlueprintParams; }
namespace search::attribute { class IAttributeVector; }
@@ -17,6 +18,7 @@ namespace search::queryeval {
class IRequestContext
{
public:
+ using MetaStoreReadGuardSP = std::shared_ptr<IDocumentMetaStoreContext::IReadGuard>;
virtual ~IRequestContext() = default;
/**
@@ -39,6 +41,8 @@ public:
virtual const vespalib::eval::Value* get_query_tensor(const vespalib::string& tensor_name) const = 0;
virtual const search::attribute::AttributeBlueprintParams& get_attribute_blueprint_params() const = 0;
+
+ virtual const MetaStoreReadGuardSP * getMetaStoreReadGuard() const = 0;
};
}
diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
index d1bb464fc37..3ccf2e9f752 100644
--- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
+++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
@@ -14,10 +14,10 @@ namespace {
};
}
-IDocumentMetaStoreContext::IReadGuard::UP
+IDocumentMetaStoreContext::IReadGuard::SP
MockDocumentMetaStoreContext::getReadGuard() const {
++get_read_guard_cnt;
- return std::make_unique<MockReadGuard>();
+ return std::make_shared<MockReadGuard>();
}
}
diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
index 97fc49ce251..5117e2b2ef3 100644
--- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
+++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
@@ -25,7 +25,7 @@ struct MockDocumentMetaStoreContext : public IDocumentMetaStoreContext {
mutable size_t get_read_guard_cnt;
MockDocumentMetaStoreContext() noexcept : get_read_guard_cnt(0) {}
- IReadGuard::UP getReadGuard() const override;
+ IReadGuard::SP getReadGuard() const override;
};
}