diff options
author | Arne H Juul <arnej27959@users.noreply.github.com> | 2020-05-18 10:36:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 10:36:31 +0200 |
commit | 62ab71c8b9f218fdbf959e38fc4ddeabfb7f61fb (patch) | |
tree | d89c2adab2c8c1817fa0f951180a373ffeda8909 /searchcore | |
parent | 51914f5d996ef405968ba44d08c25a0455ec56f8 (diff) | |
parent | 6f5a1c69ba2ed4b7eddbd0e3a0b85542626fd665 (diff) |
Merge pull request #13255 from vespa-engine/arnej/use-white-list-bitvector-as-global-filter
add a special API to get a whitelist bitvector
Diffstat (limited to 'searchcore')
6 files changed, 40 insertions, 4 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/documentmetastore/CMakeLists.txt index d257f29c9df..63ff53bb011 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/CMakeLists.txt @@ -16,6 +16,7 @@ vespa_add_library(searchcore_documentmetastore STATIC lidreusedelayer.cpp lidstatevector.cpp lid_hold_list.cpp + white_list_provider.cpp DEPENDS searchcore_attribute searchcore_bucketdb diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp index 525f4f7a267..95e8a2d738f 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_allocator.h" +#include "white_list_provider.h" #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/searchlib/fef/matchdata.h> @@ -191,7 +192,7 @@ LidAllocator::constructFreeList(DocId lidLimit) namespace { -class WhiteListBlueprint : public SimpleLeafBlueprint +class WhiteListBlueprint : public SimpleLeafBlueprint, public WhiteListProvider { private: const search::GrowableBitVector &_activeLids; @@ -199,6 +200,10 @@ private: mutable std::mutex _lock; mutable std::vector<search::fef::TermFieldMatchData *> _matchDataVector; + search::BitVector::UP get_white_list_filter() const override { + return search::BitVector::create(_activeLids); + } + SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.cpp new file mode 100644 index 00000000000..49ea1960005 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.cpp @@ -0,0 +1,3 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "white_list_provider.h" diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.h new file mode 100644 index 00000000000..99e0bf8d103 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/white_list_provider.h @@ -0,0 +1,18 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <memory> + +#pragma once + +namespace search { class BitVector; } + +namespace proton::documentmetastore { + +/** Interface for fetching a copy of the white list bitvector */ +struct WhiteListProvider { + virtual std::unique_ptr<search::BitVector> get_white_list_filter() const = 0; +protected: + ~WhiteListProvider() = default; +}; + +} // namespace diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index dd93a0eceed..d7c0ac04ce5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -13,6 +13,7 @@ #include <vespa/searchlib/query/tree/point.h> #include <vespa/searchlib/query/tree/rectangle.h> #include <vespa/searchlib/queryeval/intermediate_blueprints.h> +#include <vespa/searchcore/proton/documentmetastore/white_list_provider.h> #include <vespa/log/log.h> LOG_SETUP(".proton.matching.query"); @@ -156,6 +157,7 @@ void Query::setWhiteListBlueprint(Blueprint::UP whiteListBlueprint) { _whiteListBlueprint = std::move(whiteListBlueprint); + _white_list_provider = dynamic_cast<WhiteListProvider *>(_whiteListBlueprint.get()); } void @@ -188,11 +190,14 @@ Query::reserveHandles(const IRequestContext & requestContext, ISearchContext &co void Query::optimize() { + using search::queryeval::GlobalFilter; _blueprint = Blueprint::optimize(std::move(_blueprint)); if (_blueprint->getState().want_global_filter()) { - // XXX we need to somehow compute a real global filter - auto empty_global_filter = search::queryeval::GlobalFilter::create(); - _blueprint->set_global_filter(*empty_global_filter); + auto white_list = (_white_list_provider ? + _white_list_provider->get_white_list_filter() : + search::BitVector::UP()); + auto global_filter = GlobalFilter::create(std::move(white_list)); + _blueprint->set_global_filter(*global_filter); // optimized order may change after accounting for global filter: _blueprint = Blueprint::optimize(std::move(_blueprint)); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h index 11aade1c59b..4ca66fb7a86 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.h +++ b/searchcore/src/vespa/searchcore/proton/matching/query.h @@ -10,6 +10,8 @@ #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/irequestcontext.h> +namespace proton::documentmetastore { struct WhiteListProvider; } + namespace proton::matching { class ViewResolver; @@ -19,10 +21,12 @@ class Query { private: using Blueprint=search::queryeval::Blueprint; + using WhiteListProvider=proton::documentmetastore::WhiteListProvider; search::query::Node::UP _query_tree; Blueprint::UP _blueprint; search::fef::Location _location; Blueprint::UP _whiteListBlueprint; + WhiteListProvider *_white_list_provider; public: Query(); |