diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-05-10 10:14:03 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-05-10 10:14:03 +0000 |
commit | c038534986d6451295c242865b9b98c93d5bb75a (patch) | |
tree | f699bbdc8d2d350ec12c4e284fafff9f38bcbed6 /searchlib | |
parent | 8c35625d8c6d65f42d392ec93721548bad606a8c (diff) |
Grab the fallback guard in the constructor to ensure it is held fetching the postinglists and generating possible bitvector.
Diffstat (limited to 'searchlib')
4 files changed, 22 insertions, 10 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp index 56fcac125a6..80fca43801c 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp @@ -37,6 +37,11 @@ ImportedSearchContext::ImportedSearchContext( _useSearchCache(_imported_attribute.getSearchCache()), _searchCacheLookup((_useSearchCache ? _imported_attribute.getSearchCache()->find(_queryTerm) : std::shared_ptr<BitVectorSearchCache::Entry>())), + // Fallback in case we need to insert entry into cache, and no guard has been supplied in search context params. + // The latter will only happen for tests and docsum fetching. + _dmsReadGuardFallback((_useSearchCache && !_searchCacheLookup && (params.metaStoreReadGuard() == nullptr)) + ? _imported_attribute.getDocumentMetaStore()->getReadGuard() + : IDocumentMetaStoreContext::IReadGuard::SP()), _reference_attribute(*_imported_attribute.getReferenceAttribute()), _target_attribute(target_attribute), _target_search_context(_target_attribute.createSearchContext(std::move(term), params)), @@ -292,14 +297,15 @@ ImportedSearchContext::considerAddSearchCacheEntry() if (_useSearchCache && _merger.hasBitVector()) { IDocumentMetaStoreContext::IReadGuard::SP dmsReadGuard = (_params.metaStoreReadGuard() != nullptr) ? *_params.metaStoreReadGuard() - : _imported_attribute.getDocumentMetaStore()->getReadGuard(); + : _dmsReadGuardFallback; assert(dmsReadGuard); auto cacheEntry = std::make_shared<BitVectorSearchCache::Entry>(std::move(dmsReadGuard), _merger.getBitVectorSP(), _merger.getDocIdLimit()); _imported_attribute.getSearchCache()->insert(_queryTerm, std::move(cacheEntry)); } } -void ImportedSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) { +void +ImportedSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) { if (!_searchCacheLookup) { _target_search_context->fetchPostings(execInfo); if (!_merger.merge_done() && (execInfo.isStrict() || (_target_attribute.getIsFastSearch() && execInfo.hitRate() > 0.01))) { @@ -309,23 +315,28 @@ void ImportedSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo } } -bool ImportedSearchContext::valid() const { +bool +ImportedSearchContext::valid() const { return _target_search_context->valid(); } -Int64Range ImportedSearchContext::getAsIntegerTerm() const { +Int64Range +ImportedSearchContext::getAsIntegerTerm() const { return _target_search_context->getAsIntegerTerm(); } -DoubleRange ImportedSearchContext::getAsDoubleTerm() const { +DoubleRange +ImportedSearchContext::getAsDoubleTerm() const { return _target_search_context->getAsDoubleTerm(); } -const QueryTermUCS4 * ImportedSearchContext::queryTerm() const { +const QueryTermUCS4 * +ImportedSearchContext::queryTerm() const { return _target_search_context->queryTerm(); } -const vespalib::string& ImportedSearchContext::attributeName() const { +const vespalib::string& +ImportedSearchContext::attributeName() const { return _imported_attribute.getName(); } diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h index 7138091f599..77d09c55a41 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h @@ -33,6 +33,7 @@ class ImportedSearchContext : public ISearchContext { vespalib::string _queryTerm; bool _useSearchCache; BitVectorSearchCache::Entry::SP _searchCacheLookup; + IDocumentMetaStoreContext::IReadGuard::SP _dmsReadGuardFallback; const ReferenceAttribute& _reference_attribute; const IAttributeVector &_target_attribute; std::unique_ptr<ISearchContext> _target_search_context; diff --git a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper.h b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper.h index fbeda20da5c..d01a8edebb9 100644 --- a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper.h +++ b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper.h @@ -15,7 +15,7 @@ namespace search { class IGidToLidMapperVisitor { public: - virtual ~IGidToLidMapperVisitor() { } + virtual ~IGidToLidMapperVisitor() = default; virtual void visit(const document::GlobalId &gid, uint32_t lid) const = 0; }; @@ -28,7 +28,7 @@ public: class IGidToLidMapper { public: - virtual ~IGidToLidMapper() { } + virtual ~IGidToLidMapper() = default; virtual void foreach(const IGidToLidMapperVisitor &visitor) const = 0; }; diff --git a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h index ac104aac9c1..b463590da82 100644 --- a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h +++ b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h @@ -15,7 +15,7 @@ class IGidToLidMapperFactory { public: using SP = std::shared_ptr<IGidToLidMapperFactory>; - virtual ~IGidToLidMapperFactory() { } + virtual ~IGidToLidMapperFactory() = default; virtual std::unique_ptr<IGidToLidMapper> getMapper() const = 0; }; |