From bd2b7899f638838362c2b858f9bc28a51fb6ae85 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 4 May 2018 11:55:40 +0200 Subject: Add an optional filter to the fetchPostings interface to allow prefiltering. --- .../searchcommon/attribute/i_search_context.h | 21 +- .../documentmetastore/documentmetastore_test.cpp | 2 +- .../proton/feed_and_search/feed_and_search.cpp | 2 +- .../src/tests/proton/index/fusionrunner_test.cpp | 2 +- .../match_phase_limiter_test.cpp | 12 +- .../src/tests/proton/matching/query_test.cpp | 10 +- .../src/tests/proton/matching/querynodes_test.cpp | 2 +- .../proton/documentmetastore/lid_allocator.cpp | 18 +- .../proton/matching/attribute_limiter.cpp | 11 +- .../src/vespa/searchcore/proton/matching/query.cpp | 2 +- .../src/apps/tests/memoryindexstress_test.cpp | 4 +- .../tests/attribute/benchmark/attributesearcher.h | 6 +- .../tests/attribute/bitvector/bitvector_test.cpp | 224 ++++++--------------- .../enumeratedsave/enumeratedsave_test.cpp | 5 +- .../imported_search_context_test.cpp | 18 +- .../postinglistattribute_test.cpp | 12 +- .../attribute_searchable_adapter_test.cpp | 2 +- .../attribute_weighted_set_blueprint_test.cpp | 4 +- .../searchable/attributeblueprint_test.cpp | 2 +- .../attribute/searchcontext/searchcontext.cpp | 16 +- .../tests/diskindex/diskindex/diskindex_test.cpp | 8 +- .../memoryindex/memoryindex/memoryindex_test.cpp | 4 +- searchlib/src/tests/nearsearch/nearsearch_test.cpp | 2 +- .../tests/queryeval/blueprint/blueprint_test.cpp | 2 +- .../blueprint/intermediate_blueprints_test.cpp | 16 +- .../queryeval/blueprint/leaf_blueprints_test.cpp | 6 +- searchlib/src/tests/queryeval/blueprint/mysearch.h | 1 + .../queryeval/dot_product/dot_product_test.cpp | 2 +- searchlib/src/tests/queryeval/equiv/equiv_test.cpp | 2 +- .../fake_searchable/fake_searchable_test.cpp | 10 +- .../parallel_weak_and/parallel_weak_and_test.cpp | 4 +- .../predicate/predicate_blueprint_test.cpp | 10 +- searchlib/src/tests/queryeval/queryeval.cpp | 12 +- .../queryeval/simple_phrase/simple_phrase_test.cpp | 4 +- .../queryeval/sourceblender/sourceblender.cpp | 2 +- .../weighted_set_term/weighted_set_term_test.cpp | 8 +- .../src/vespa/searchlib/attribute/attribute.h | 8 +- .../attribute/attribute_blueprint_factory.cpp | 8 +- .../attribute/attribute_weighted_set_blueprint.cpp | 4 +- .../attribute/attribute_weighted_set_blueprint.h | 2 +- .../vespa/searchlib/attribute/attributevector.cpp | 16 +- .../vespa/searchlib/attribute/attributevector.h | 28 +-- .../src/vespa/searchlib/attribute/diversity.h | 8 +- .../src/vespa/searchlib/attribute/diversity.hpp | 10 +- .../searchlib/attribute/enumhintsearchcontext.cpp | 21 +- .../searchlib/attribute/enumhintsearchcontext.h | 14 +- .../attribute/imported_search_context.cpp | 7 +- .../searchlib/attribute/imported_search_context.h | 2 +- .../attribute/ipostinglistsearchcontext.h | 19 +- .../searchlib/attribute/postinglistsearchcontext.h | 8 +- .../attribute/postinglistsearchcontext.hpp | 5 +- .../searchlib/diskindex/disktermblueprint.cpp | 9 +- .../vespa/searchlib/diskindex/disktermblueprint.h | 2 +- .../src/vespa/searchlib/queryeval/blueprint.cpp | 16 +- .../src/vespa/searchlib/queryeval/blueprint.h | 25 ++- .../searchlib/queryeval/dot_product_blueprint.cpp | 4 +- .../searchlib/queryeval/dot_product_blueprint.h | 5 +- .../vespa/searchlib/queryeval/equiv_blueprint.cpp | 14 +- .../vespa/searchlib/queryeval/equiv_blueprint.h | 10 +- .../searchlib/queryeval/predicate_blueprint.cpp | 11 +- .../searchlib/queryeval/predicate_blueprint.h | 14 +- .../queryeval/simple_phrase_blueprint.cpp | 10 +- .../searchlib/queryeval/simple_phrase_blueprint.h | 6 +- .../queryeval/wand/parallel_weak_and_blueprint.cpp | 10 +- .../queryeval/wand/parallel_weak_and_blueprint.h | 9 +- .../queryeval/weighted_set_term_blueprint.cpp | 4 +- .../queryeval/weighted_set_term_blueprint.h | 2 +- 67 files changed, 319 insertions(+), 460 deletions(-) diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h index 4be1f00dcbc..257f63c937c 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h +++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h @@ -5,18 +5,15 @@ #include #include -namespace search { -namespace fef { - class TermFieldMatchData; -} -namespace queryeval { - class SearchIterator; +namespace search::fef { class TermFieldMatchData; } +namespace search::queryeval { class SearchIterator; } +namespace search { + class QueryTermBase; + class BitVector; } -class QueryTermBase; - -namespace attribute { +namespace search::attribute { class ISearchContext { public: @@ -49,8 +46,11 @@ public: /* * Create temporary posting lists. * Should be called before createIterator() is called. + * Will load/prepare any postings lists. Will take strictness and optional filter into account. + * @param strict If true iterator must advance to next valid docid. + * @param filter Any prefilter that can be applied to posting lists for optimization purposes. */ - virtual void fetchPostings(bool strict) = 0; + virtual void fetchPostings(bool strict, const BitVector * filter) = 0; virtual bool valid() const = 0; virtual Int64Range getAsIntegerTerm() const = 0; @@ -63,4 +63,3 @@ public: }; } -} diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index 0a2f4973ce2..307556cd82b 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -202,7 +202,7 @@ assertWhiteList(const SimpleResult &exp, Blueprint::UP whiteListBlueprint, bool { MatchDataLayout mdl; MatchData::UP md = mdl.createMatchData(); - whiteListBlueprint->fetchPostings(strict); + whiteListBlueprint->fetchPostings(strict, nullptr); whiteListBlueprint->setDocIdLimit(docIdLimit); SearchIterator::UP sb = whiteListBlueprint->createSearch(*md, strict); diff --git a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp index e851e30a31d..1c38cd68410 100644 --- a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp +++ b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp @@ -122,7 +122,7 @@ void Test::testSearch(Searchable &source, SimpleStringTerm node(term, field_name, 0, search::query::Weight(0)); Blueprint::UP result = source.createBlueprint(requestContext, FieldSpecList().add(FieldSpec(field_name, 0, handle)), node); - result->fetchPostings(true); + result->fetchPostings(true, nullptr); SearchIterator::UP search_iterator = result->createSearch(*match_data, true); search_iterator->initFullRange(); diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp index e6efa246484..5fad735a3ff 100644 --- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp +++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp @@ -235,7 +235,7 @@ void Test::checkResults(uint32_t fusion_id, const uint32_t *ids, size_t size) { search::queryeval::Searchable &searchable = disk_index; SimpleStringTerm node(term, field_name, fieldId, search::query::Weight(0)); Blueprint::UP blueprint = searchable.createBlueprint(requestContext, fields, node); - blueprint->fetchPostings(true); + blueprint->fetchPostings(true, nullptr); SearchIterator::UP search = blueprint->createSearch(*match_data, true); search->initFullRange(); for (size_t i = 0; i < size; ++i) { diff --git a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp index b153b2ca5e0..9d33b88cca9 100644 --- a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp +++ b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp @@ -4,6 +4,7 @@ #include #include #include +#include using namespace proton::matching; using search::queryeval::SearchIterator; @@ -57,8 +58,8 @@ struct MockBlueprint : SimpleLeafBlueprint { { setEstimate(HitEstimate(756, false)); } - virtual SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, - bool strict) const override + SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, + bool strict) const override { if (postings_fetched) { EXPECT_EQUAL(postings_strict, strict); @@ -66,7 +67,7 @@ struct MockBlueprint : SimpleLeafBlueprint { return SearchIterator::UP(new MockSearch(spec, term, strict, tfmda, postings_fetched)); } - virtual void fetchPostings(bool strict) override { + void fetchPostings(bool strict, const search::BitVector *) override { postings_strict = strict; postings_fetched = true; } @@ -74,9 +75,8 @@ struct MockBlueprint : SimpleLeafBlueprint { struct MockSearchable : Searchable { size_t create_cnt = 0; - virtual Blueprint::UP createBlueprint(const search::queryeval::IRequestContext & requestContext, - const FieldSpec &field, - const search::query::Node &term) override + Blueprint::UP createBlueprint(const search::queryeval::IRequestContext & requestContext, + const FieldSpec &field, const search::query::Node &term) override { (void) requestContext; ++create_cnt; diff --git a/searchcore/src/tests/proton/matching/query_test.cpp b/searchcore/src/tests/proton/matching/query_test.cpp index eb49603f71d..78db70f92dc 100644 --- a/searchcore/src/tests/proton/matching/query_test.cpp +++ b/searchcore/src/tests/proton/matching/query_test.cpp @@ -418,7 +418,7 @@ SearchIterator::UP Test::getIterator(Node &node, ISearchContext &context) { _blueprint = BlueprintBuilder::build(_requestContext, node, context); - _blueprint->fetchPostings(true); + _blueprint->fetchPostings(true, nullptr); SearchIterator::UP search(_blueprint->createSearch(*_match_data, true)); search->initFullRange(); return search; @@ -731,10 +731,10 @@ Test::requireThatFakeFieldSearchDumpsDiffer() Blueprint::UP l3(a.createBlueprint(requestContext, fields2, n3)); // field Blueprint::UP l4(b.createBlueprint(requestContext, fields1, n1)); // tag - l1->fetchPostings(true); - l2->fetchPostings(true); - l3->fetchPostings(true); - l4->fetchPostings(true); + l1->fetchPostings(true, nullptr); + l2->fetchPostings(true, nullptr); + l3->fetchPostings(true, nullptr); + l4->fetchPostings(true, nullptr); SearchIterator::UP s1(l1->createSearch(*match_data, true)); SearchIterator::UP s2(l2->createSearch(*match_data, true)); diff --git a/searchcore/src/tests/proton/matching/querynodes_test.cpp b/searchcore/src/tests/proton/matching/querynodes_test.cpp index f8a419ba15b..7ab4fc9c8d4 100644 --- a/searchcore/src/tests/proton/matching/querynodes_test.cpp +++ b/searchcore/src/tests/proton/matching/querynodes_test.cpp @@ -202,7 +202,7 @@ public: MatchData::UP match_data = mdl.createMatchData(); Blueprint::UP blueprint = BlueprintBuilder::build(requestContext, node, context); - blueprint->fetchPostings(true); + blueprint->fetchPostings(true, nullptr); return blueprint->createSearch(*match_data, true)->asString(); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp index 63d815ffe82..4fd3ee94559 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -3,6 +3,7 @@ #include "lid_allocator.h" #include #include +#include #include #include @@ -17,9 +18,7 @@ using vespalib::GenerationHolder; namespace proton::documentmetastore { -LidAllocator::LidAllocator(uint32_t size, - uint32_t capacity, - GenerationHolder &genHolder) +LidAllocator::LidAllocator(uint32_t size, uint32_t capacity, GenerationHolder &genHolder) : _holdLids(), _freeLids(size, capacity, genHolder, true, false), _usedLids(size, capacity, genHolder, false, true), @@ -31,7 +30,7 @@ LidAllocator::LidAllocator(uint32_t size, } -LidAllocator::~LidAllocator() {} +LidAllocator::~LidAllocator() = default; LidAllocator::DocId LidAllocator::getFreeLid(DocId lidLimit) @@ -56,8 +55,7 @@ LidAllocator::peekFreeLid(DocId lidLimit) } void -LidAllocator::ensureSpace(uint32_t newSize, - uint32_t newCapacity) +LidAllocator::ensureSpace(uint32_t newSize, uint32_t newCapacity) { _freeLids.resizeVector(newSize, newCapacity); _usedLids.resizeVector(newSize, newCapacity); @@ -120,9 +118,7 @@ LidAllocator::moveLidEnd(DocId fromLid, DocId toLid) } void -LidAllocator::holdLid(DocId lid, - DocId lidLimit, - generation_t currentGeneration) +LidAllocator::holdLid(DocId lid, DocId lidLimit, generation_t currentGeneration) { (void) lidLimit; assert(holdLidOK(lid, lidLimit)); @@ -135,9 +131,7 @@ LidAllocator::holdLid(DocId lid, } void -LidAllocator::holdLids(const std::vector &lids, - DocId lidLimit, - generation_t currentGeneration) +LidAllocator::holdLids(const std::vector &lids, DocId lidLimit, generation_t currentGeneration) { (void) lidLimit; for (const auto &lid : lids) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp index 05dc75146c7..4c01d877ab9 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp @@ -11,8 +11,7 @@ using namespace search::query; using vespalib::make_string; using vespalib::string; -namespace proton { -namespace matching { +namespace proton::matching { AttributeLimiter::AttributeLimiter(Searchable &searchable_attributes, const IRequestContext & requestContext, @@ -35,7 +34,7 @@ AttributeLimiter::AttributeLimiter(Searchable &searchable_attributes, { } -AttributeLimiter::~AttributeLimiter() {} +AttributeLimiter::~AttributeLimiter() = default; namespace { @@ -78,7 +77,8 @@ AttributeLimiter::create_search(size_t want_hits, size_t max_group_size, bool st FieldSpecList field; // single field API is protected field.add(FieldSpec(_attribute_name, my_field_id, my_handle)); _blueprint = _searchable_attributes.createBlueprint(_requestContext, field, node); - _blueprint->fetchPostings(strictSearch); + //TODO: Put in any bitvectors from termwise eval here. + _blueprint->fetchPostings(strictSearch, nullptr); _estimatedHits = _blueprint->getState().estimate().estHits; _blueprint->freeze(); } @@ -86,5 +86,4 @@ AttributeLimiter::create_search(size_t want_hits, size_t max_group_size, bool st return _blueprint->createSearch(*_match_datas.back(), strictSearch); } -} // namespace proton::matching -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index 9181205bb19..a7e8c4d2f71 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -146,7 +146,7 @@ Query::optimize() void Query::fetchPostings() { - _blueprint->fetchPostings(true); + _blueprint->fetchPostings(true, nullptr); } void diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index edb9160a1fb..b5a11c70ec2 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -317,7 +317,7 @@ Fixture::readWork(uint32_t cnt) } else { ++nonEmptyCount; } - result->fetchPostings(true); + result->fetchPostings(true, nullptr); SearchIterator::UP search = result->createSearch(*match_data, true); if (!EXPECT_TRUE(search.get() != 0)) { LOG(error, "Did not get search iterator"); @@ -412,7 +412,7 @@ verifyResult(const FakeResult &expect, EXPECT_EQUAL(expect.inspect().size(), result->getState().estimate().estHits); EXPECT_EQUAL(expect.inspect().empty(), result->getState().estimate().empty); - result->fetchPostings(true); + result->fetchPostings(true, nullptr); SearchIterator::UP search = result->createSearch(*match_data, true); if (!EXPECT_TRUE(search.get() != 0)) { return false; diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h index f8cd614c48c..b79e0fce911 100644 --- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -133,7 +133,7 @@ AttributeFindSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(true, nullptr); std::unique_ptr iterator = searchContext->createIterator(NULL, true); std::unique_ptr results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -211,7 +211,7 @@ AttributeRangeSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(true, nullptr); std::unique_ptr iterator = searchContext->createIterator(NULL, true); std::unique_ptr results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -250,7 +250,7 @@ AttributePrefixSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(true, nullptr); std::unique_ptr iterator = searchContext->createIterator(NULL, true); std::unique_ptr results = performSearch(*iterator, _attrPtr->getNumDocs()); diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp index c00ab1270e3..d725a9a3ed5 100644 --- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp @@ -51,76 +51,44 @@ struct BitVectorTest StringAttribute & asString(AttributePtr &v); FloatingPointAttribute & asFloat(AttributePtr &v); - AttributePtr - make(Config cfg, - const vespalib::string &pref, - bool fastSearch, - bool enableBitVectors, - bool enableOnlyBitVector, - bool filter); + AttributePtr make(Config cfg, const vespalib::string &pref, bool fastSearch, + bool enableBitVectors, bool enableOnlyBitVector, bool filter); - void - addDocs(const AttributePtr &v, size_t sz); + void addDocs(const AttributePtr &v, size_t sz); template - void populate(VectorType &v, - uint32_t low, - uint32_t high, - bool set); + void populate(VectorType &v, uint32_t low, uint32_t high, bool set); template - void populateAll(VectorType &v, - uint32_t low, - uint32_t high, - bool set); + void populateAll(VectorType &v, uint32_t low, uint32_t high, bool set); - void - buildTermQuery(std::vector & buffer, - const vespalib::string & index, - const vespalib::string & term, bool prefix); + void buildTermQuery(std::vector & buffer, + const vespalib::string & index, + const vespalib::string & term, bool prefix); template - vespalib::string - getSearchStr(); + vespalib::string getSearchStr(); template - SearchContextPtr - getSearch(const V & vec, const T & term, bool prefix, bool useBitVector); + SearchContextPtr getSearch(const V & vec, const T & term, bool prefix, bool useBitVector); template - SearchContextPtr - getSearch(const V & vec, bool useBitVector); - - void - checkSearch(AttributePtr v, - SearchBasePtr sb, - TermFieldMatchData &md, - uint32_t expFirstDocId, - uint32_t expFastDocId, - uint32_t expDocFreq, - bool weights, - bool checkStride); - - void - checkSearch(AttributePtr v, - SearchContextPtr sc, - uint32_t expFirstDocId, - uint32_t expLastDocId, - uint32_t expDocFreq, - bool weights, - bool checkStride); + SearchContextPtr getSearch(const V & vec, bool useBitVector); + + void checkSearch(AttributePtr v, SearchBasePtr sb, TermFieldMatchData &md, + uint32_t expFirstDocId, uint32_t expFastDocId, uint32_t expDocFreq, + bool weights, bool checkStride); + + void checkSearch(AttributePtr v, SearchContextPtr sc, + uint32_t expFirstDocId, uint32_t expLastDocId, uint32_t expDocFreq, + bool weights, bool checkStride); template - void - test(BasicType bt, CollectionType ct, const vespalib::string &pref, - bool fastSearch, - bool enableBitVectors, - bool enableOnlyBitVector, - bool filter); + void test(BasicType bt, CollectionType ct, const vespalib::string &pref, bool fastSearch, + bool enableBitVectors, bool enableOnlyBitVector, bool filter); template - void - test(BasicType bt, CollectionType ct, const vespalib::string &pref); + void test(BasicType bt, CollectionType ct, const vespalib::string &pref); }; @@ -156,10 +124,8 @@ BitVectorTest::asFloat(AttributePtr &v) void -BitVectorTest::buildTermQuery(std::vector &buffer, - const vespalib::string &index, - const vespalib::string &term, - bool prefix) +BitVectorTest::buildTermQuery(std::vector &buffer, const vespalib::string &index, + const vespalib::string &term, bool prefix) { uint32_t indexLen = index.size(); uint32_t termLen = term.size(); @@ -201,8 +167,7 @@ BitVectorTest::getSearchStr() template SearchContextPtr -BitVectorTest::getSearch(const V &vec, const T &term, bool prefix, - bool useBitVector) +BitVectorTest::getSearch(const V &vec, const T &term, bool prefix, bool useBitVector) { std::vector query; vespalib::asciistream ss; @@ -217,8 +182,7 @@ BitVectorTest::getSearch(const V &vec, const T &term, bool prefix, template <> SearchContextPtr -BitVectorTest::getSearch(const IntegerAttribute &v, - bool useBitVector) +BitVectorTest::getSearch(const IntegerAttribute &v, bool useBitVector) { return getSearch(v, "[-42;-42]", false, useBitVector); } @@ -226,30 +190,22 @@ BitVectorTest::getSearch(const IntegerAttribute &v, template <> SearchContextPtr BitVectorTest:: -getSearch(const FloatingPointAttribute &v, - bool useBitVector) +getSearch(const FloatingPointAttribute &v, bool useBitVector) { - return getSearch(v, "[-42.0;-42.0]", false, - useBitVector); + return getSearch(v, "[-42.0;-42.0]", false, useBitVector); } template <> SearchContextPtr -BitVectorTest::getSearch(const StringAttribute &v, - bool useBitVector) +BitVectorTest::getSearch(const StringAttribute &v, bool useBitVector) { - return getSearch - (v, "foo", false, useBitVector); + return getSearch(v, "foo", false, useBitVector); } BitVectorTest::AttributePtr -BitVectorTest::make(Config cfg, - const vespalib::string &pref, - bool fastSearch, - bool enableBitVectors, - bool enableOnlyBitVector, - bool filter) +BitVectorTest::make(Config cfg, const vespalib::string &pref, bool fastSearch, bool enableBitVectors, + bool enableOnlyBitVector, bool filter) { cfg.setFastSearch(fastSearch); cfg.setEnableBitVectors(enableBitVectors); @@ -275,9 +231,7 @@ BitVectorTest::addDocs(const AttributePtr &v, size_t sz) template <> void -BitVectorTest::populate(IntegerAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populate(IntegerAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; i+= 5) { if (!set) { @@ -296,9 +250,7 @@ BitVectorTest::populate(IntegerAttribute &v, template <> void -BitVectorTest::populate(FloatingPointAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populate(FloatingPointAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; i+= 5) { if (!set) { @@ -317,9 +269,7 @@ BitVectorTest::populate(FloatingPointAttribute &v, template <> void -BitVectorTest::populate(StringAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populate(StringAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; i+= 5) { if (!set) { @@ -337,9 +287,7 @@ BitVectorTest::populate(StringAttribute &v, template <> void -BitVectorTest::populateAll(IntegerAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populateAll(IntegerAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; ++i) { if (!set) { @@ -359,9 +307,7 @@ BitVectorTest::populateAll(IntegerAttribute &v, template <> void -BitVectorTest::populateAll(FloatingPointAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populateAll(FloatingPointAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; ++i) { if (!set) { @@ -381,9 +327,7 @@ BitVectorTest::populateAll(FloatingPointAttribute &v, template <> void -BitVectorTest::populateAll(StringAttribute &v, - uint32_t low, uint32_t high, - bool set) +BitVectorTest::populateAll(StringAttribute &v, uint32_t low, uint32_t high, bool set) { for(size_t i(low), m(high); i < m; ++i) { if (!set) { @@ -402,14 +346,9 @@ BitVectorTest::populateAll(StringAttribute &v, void -BitVectorTest::checkSearch(AttributePtr v, - SearchBasePtr sb, - TermFieldMatchData &md, - uint32_t expFirstDocId, - uint32_t expLastDocId, - uint32_t expDocFreq, - bool weights, - bool checkStride) +BitVectorTest::checkSearch(AttributePtr v, SearchBasePtr sb, TermFieldMatchData &md, + uint32_t expFirstDocId, uint32_t expLastDocId, uint32_t expDocFreq, + bool weights, bool checkStride) { (void) checkStride; sb->initRange(1, v->getCommittedDocIdLimit()); @@ -445,16 +384,12 @@ BitVectorTest::checkSearch(AttributePtr v, void -BitVectorTest::checkSearch(AttributePtr v, - SearchContextPtr sc, - uint32_t expFirstDocId, - uint32_t expLastDocId, - uint32_t expDocFreq, - bool weights, - bool checkStride) +BitVectorTest::checkSearch(AttributePtr v, SearchContextPtr sc, + uint32_t expFirstDocId, uint32_t expLastDocId, uint32_t expDocFreq, + bool weights, bool checkStride) { TermFieldMatchData md; - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); checkSearch(v, std::move(sb), md, expFirstDocId, expLastDocId, expDocFreq, weights, @@ -464,27 +399,19 @@ BitVectorTest::checkSearch(AttributePtr v, template void -BitVectorTest::test(BasicType bt, - CollectionType ct, - const vespalib::string &pref, - bool fastSearch, - bool enableBitVectors, - bool enableOnlyBitVector, - bool filter) +BitVectorTest::test(BasicType bt, CollectionType ct, const vespalib::string &pref, bool fastSearch, + bool enableBitVectors, bool enableOnlyBitVector, bool filter) { Config cfg(bt, ct); - AttributePtr v = make(cfg, pref, fastSearch, - enableBitVectors, enableOnlyBitVector, filter); + AttributePtr v = make(cfg, pref, fastSearch, enableBitVectors, enableOnlyBitVector, filter); addDocs(v, 1024); VectorType &tv = as(v); populate(tv, 2, 1023, true); SearchContextPtr sc = getSearch(tv, true); - checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, - true); + checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, true); sc = getSearch(tv, false); - checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && - !filter, true); + checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && !filter, true); const search::IDocumentWeightAttribute *dwa = v->asDocumentWeightAttribute(); if (dwa != NULL) { @@ -503,21 +430,16 @@ BitVectorTest::test(BasicType bt, } populate(tv, 2, 973, false); sc = getSearch(tv, true); - checkSearch(v, std::move(sc), 977, 1022, 10, !enableOnlyBitVector && - !filter, true); + checkSearch(v, std::move(sc), 977, 1022, 10, !enableOnlyBitVector && !filter, true); populate(tv, 2, 973, true); sc = getSearch(tv, true); - checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, - true); + checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, true); addDocs(v, 15000); sc = getSearch(tv, true); - checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && - !filter, true); + checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && !filter, true); populateAll(tv, 10, 15000, true); sc = getSearch(tv, true); - checkSearch(v, std::move(sc), 2, 14999, 14992, - !enableBitVectors && !filter, - false); + checkSearch(v, std::move(sc), 2, 14999, 14992, !enableBitVectors && !filter, false); } @@ -540,73 +462,55 @@ BitVectorTest::test(BasicType bt, CollectionType ct, const vespalib::string &pre TEST_F("Test bitvectors with single value int32", BitVectorTest) { f.template test(BasicType::INT32, - CollectionType::SINGLE, - "int32_sv"); + IntegerAttribute::largeint_t>(BasicType::INT32, CollectionType::SINGLE, "int32_sv"); } TEST_F("Test bitvectors with array value int32", BitVectorTest) { f.template test(BasicType::INT32, - CollectionType::ARRAY, - "int32_a"); + IntegerAttribute::largeint_t>(BasicType::INT32, CollectionType::ARRAY, "int32_a"); } TEST_F("Test bitvectors with weighted set value int32", BitVectorTest) { f.template test(BasicType::INT32, - CollectionType::WSET, - "int32_sv"); + IntegerAttribute::WeightedInt>(BasicType::INT32, CollectionType::WSET, "int32_sv"); } TEST_F("Test bitvectors with single value double", BitVectorTest) { f.template test(BasicType::DOUBLE, - CollectionType::SINGLE, - "double_sv"); + double>(BasicType::DOUBLE, CollectionType::SINGLE, "double_sv"); } TEST_F("Test bitvectors with array value double", BitVectorTest) { f.template test(BasicType::DOUBLE, - CollectionType::ARRAY, - "double_a"); + double>(BasicType::DOUBLE, CollectionType::ARRAY, "double_a"); } TEST_F("Test bitvectors with weighted set value double", BitVectorTest) { f.template test(BasicType::DOUBLE, - CollectionType::WSET, - "double_ws"); + FloatingPointAttribute::WeightedFloat>(BasicType::DOUBLE, CollectionType::WSET, "double_ws"); } TEST_F("Test bitvectors with single value string", BitVectorTest) { f.template test(BasicType::STRING, - CollectionType::SINGLE, - "string_sv"); + vespalib::string>(BasicType::STRING, CollectionType::SINGLE, "string_sv"); } TEST_F("Test bitvectors with array value string", BitVectorTest) { f.template test(BasicType::STRING, - CollectionType::ARRAY, - "string_a"); + vespalib::string>(BasicType::STRING, CollectionType::ARRAY, "string_a"); } TEST_F("Test bitvectors with weighted set value string", BitVectorTest) { f.template test(BasicType::STRING, - CollectionType::WSET, - "string_ws"); + StringAttribute::WeightedString>(BasicType::STRING, CollectionType::WSET, "string_ws"); } @@ -631,7 +535,7 @@ Verifier::Verifier() _bv->setBit(docId); } } -Verifier::~Verifier() {} +Verifier::~Verifier() = default; TEST("Test that bitvector iterators adheres to SearchIterator requirements") { Verifier searchIteratorVerifier; diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index 7fb915a6175..fba2af8d07b 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -694,7 +694,7 @@ EnumeratedSaveTest::testReload(AttributePtr v0, TermFieldMatchData md; SearchContextPtr sc = getSearch(as(v)); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); sb->initFullRange(); sb->seek(1u); @@ -718,8 +718,7 @@ EnumeratedSaveTest::testReload(AttributePtr v0, template void -EnumeratedSaveTest::test(BasicType bt, CollectionType ct, - const vespalib::string &pref) +EnumeratedSaveTest::test(BasicType bt, CollectionType ct, const vespalib::string &pref) { Config cfg(bt, ct); AttributePtr v0 = AttributeFactory::createAttribute(pref + "0", cfg); 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 e8e16ffcc98..14026b85ef9 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 @@ -209,7 +209,7 @@ TEST_F("Non-strict iterator unpacks target match data for weighted set hit", Wse TEST_F("Strict iterator is marked as strict", Fixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -231,7 +231,7 @@ struct SingleValueFixture : Fixture { TEST_F("Strict iterator seeks to first available hit LID", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -257,7 +257,7 @@ TEST_F("Strict iterator seeks to first available hit LID", SingleValueFixture) { TEST_F("Strict iterator unpacks target match data for single value hit", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -269,7 +269,7 @@ TEST_F("Strict iterator unpacks target match data for single value hit", SingleV TEST_F("Strict iterator unpacks target match data for array hit", ArrayValueFixture) { auto ctx = f.create_context(word_term("1234")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -281,7 +281,7 @@ TEST_F("Strict iterator unpacks target match data for array hit", ArrayValueFixt TEST_F("Strict iterator unpacks target match data for weighted set hit", WsetValueFixture) { auto ctx = f.create_context(word_term("foo")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -292,7 +292,7 @@ TEST_F("Strict iterator unpacks target match data for weighted set hit", WsetVal TEST_F("Strict iterator handles seek outside of LID space", ArrayValueFixture) { auto ctx = f.create_context(word_term("1234")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -324,7 +324,7 @@ TEST_F("cmp(weight) performs GID mapping and forwards to target attribute", Wset TEST_F("Multiple iterators can be created from the same context", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match1; auto iter1 = f.create_strict_iterator(*ctx, match1); @@ -379,7 +379,7 @@ TEST_F("Bit vector from search cache is used if found", SearchCacheFixture) f.imported_attr->getSearchCache()->insert("5678", makeSearchCacheEntry({2, 6}, f.get_imported_attr()->getNumDocs())); auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); TEST_DO(f.assertSearch({2, 6}, *iter)); // Note: would be {3, 5} if cache was not used @@ -398,7 +398,7 @@ TEST_F("Entry is inserted into search cache if bit vector posting list is used", { EXPECT_EQUAL(0u, f.imported_attr->getSearchCache()->size()); auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(true, nullptr); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); TEST_DO(f.assertSearch({3, 5}, *iter)); diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp index 9d9aaac9f62..18cd56f397a 100644 --- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp +++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp @@ -375,7 +375,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch(sa); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb))) return false; @@ -388,7 +388,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch(sa, key, false); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -400,7 +400,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, IntegerAttribute { TermFieldMatchData md; SearchContextPtr sc = getSearch(ia, key, false); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -479,7 +479,7 @@ PostingListAttributeTest::checkSearch(bool useBitVector, const AttributeVector & { SearchContextPtr sc = getSearch(vec, term, false, attribute::SearchContextParams().useBitVector(useBitVector)); EXPECT_FALSE( ! sc ); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); size_t approx = sc->approximateHits(); EXPECT_EQUAL(numHits, approx); if (docBegin == 0) { @@ -906,7 +906,7 @@ PostingListAttributeTest::testMinMax(AttributePtr &ptr1, uint32_t trimmed) { TermFieldMatchData md; SearchContextPtr sc = getSearch(as(ptr1)); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&md, true); sb->initFullRange(); @@ -932,7 +932,7 @@ PostingListAttributeTest::testMinMax(AttributePtr &ptr1, uint32_t trimmed) EXPECT_EQUAL(1u, sb->getDocId()); sc = getSearch2(as(ptr1)); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); sb = sc->createIterator(&md, true); sb->initFullRange(); diff --git a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp index e5af6931977..e479b17c0a8 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -201,7 +201,7 @@ Result do_search(IAttributeManager &attribute_manager, const Node &node, bool st Blueprint::UP bp = source.createBlueprint(requestContext, FieldSpec(field, fieldId, handle), node); ASSERT_TRUE(bp.get() != nullptr); Result result(bp->getState().estimate().estHits, bp->getState().estimate().empty); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP iterator = bp->createSearch(*match_data, strict); ASSERT_TRUE(iterator.get() != nullptr); iterator->initRange(1, num_docs); diff --git a/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp index 39bbb8fb5ad..d94800f593e 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp @@ -153,7 +153,7 @@ struct WS { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP sb = bp->createSearch(*md, strict); return (dynamic_cast(sb.get()) != 0); } @@ -165,7 +165,7 @@ struct WS { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP sb = bp->createSearch(*md, strict); FakeResult result; sb->initRange(1, 10); diff --git a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp index dc7cf53d188..0573a63cddb 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -91,7 +91,7 @@ bool search(const Node &node, IAttributeManager &attribute_manager) { ASSERT_TRUE(result.get()); EXPECT_TRUE(!result->getState().estimate().empty); EXPECT_EQUAL(3u, result->getState().estimate().estHits); - result->fetchPostings(true); + result->fetchPostings(true, nullptr); result->setDocIdLimit(DOCID_LIMIT); SearchIterator::UP iterator = result->createSearch(*md, true); ASSERT_TRUE((bool)iterator); diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp index cbc86b02ada..9fc392d9592 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -446,7 +446,7 @@ SearchContextTest::performSearch(const V & vec, const T & term, QueryTermSimple: { TermFieldMatchData dummy; SearchContextPtr sc = getSearch(vec, term, termType); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, vec.getNumDocs()); return rs; @@ -504,7 +504,7 @@ SearchContextTest::testFind(const PostingList & pl) { { // strict search iterator SearchContextPtr sc = getSearch(pl.getAttribute(), pl.getValue()); - sc->fetchPostings(true); + sc->fetchPostings(true, nullptr); TermFieldMatchData dummy; SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, pl.getAttribute().getNumDocs()); @@ -644,7 +644,7 @@ Verifier::Verifier(T key, const vespalib::string & keyAsString, const vesp _attribute->commit(true); _sc = SearchContextTest::getSearch(*_attribute, keyAsString); ASSERT_TRUE(_sc->valid()); - _sc->fetchPostings(true); + _sc->fetchPostings(true, nullptr); } template @@ -721,7 +721,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with 3 hits - threeHits.fetchPostings(true); + threeHits.fetchPostings(true, nullptr); SearchBasePtr sb = threeHits.createIterator(&dummy, true); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -742,7 +742,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, } { // search for value with no hits - noHits.fetchPostings(true); + noHits.fetchPostings(true, nullptr); SearchBasePtr sb = noHits.createIterator(&dummy, true); sb->initRange(1, noHits.attribute().getCommittedDocIdLimit()); ASSERT_TRUE(typeTester.matches(*sb)); @@ -760,7 +760,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with three hits - threeHits.fetchPostings(false); + threeHits.fetchPostings(false, nullptr); SearchBasePtr sb = threeHits.createIterator(&dummy, false); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -778,7 +778,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, EXPECT_TRUE(sb->getDocId() == 5u || sb->isAtEnd()); } { // search for value with no hits - noHits.fetchPostings(false); + noHits.fetchPostings(false, nullptr); SearchBasePtr sb = noHits.createIterator(&dummy, false); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); @@ -950,7 +950,7 @@ SearchContextTest::testSearchIteratorUnpacking(const AttributePtr & attr, pos.setElementWeight(100); md.appendPosition(pos); - sc.fetchPostings(strict); + sc.fetchPostings(strict, nullptr); SearchBasePtr sb = sc.createIterator(&md, strict); sb->initFullRange(); diff --git a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp index ba266a85470..e7e9bd3a240 100644 --- a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp +++ b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp @@ -244,13 +244,13 @@ Test::requireThatBlueprintCanCreateSearchIterators() SearchIterator::UP s; { // bit vector due to isFilter b = _index->createBlueprint(_requestContext, FieldSpec("f2", 0, 0, true), makeTerm("w2")); - b->fetchPostings(true); + b->fetchPostings(true, nullptr); s = (dynamic_cast(b.get()))->createLeafSearch(mda, true); EXPECT_TRUE(dynamic_cast(s.get()) != NULL); } { // bit vector due to no ranking needed b = _index->createBlueprint(_requestContext, FieldSpec("f2", 0, 0, false), makeTerm("w2")); - b->fetchPostings(true); + b->fetchPostings(true, nullptr); s = (dynamic_cast(b.get()))->createLeafSearch(mda, true); EXPECT_FALSE(dynamic_cast(s.get()) != NULL); TermFieldMatchData md2; @@ -264,7 +264,7 @@ Test::requireThatBlueprintCanCreateSearchIterators() { // fake bit vector b = _index->createBlueprint(_requestContext, FieldSpec("f1", 0, 0, true), makeTerm("w2")); // std::cerr << "BP = " << typeid(*b).name() << std::endl; - b->fetchPostings(true); + b->fetchPostings(true, nullptr); s = (dynamic_cast(b.get()))->createLeafSearch(mda, true); // std::cerr << "SI = " << typeid(*s).name() << std::endl; EXPECT_TRUE((dynamic_cast(s.get()) != NULL) || @@ -272,7 +272,7 @@ Test::requireThatBlueprintCanCreateSearchIterators() } { // posting list iterator b = _index->createBlueprint(_requestContext, FieldSpec("f1", 0, 0), makeTerm("w1")); - b->fetchPostings(true); + b->fetchPostings(true, nullptr); s = (dynamic_cast(b.get()))->createLeafSearch(mda, true); ASSERT_TRUE(dynamic_cast *>(s.get()) != NULL); } diff --git a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp index 9de6ac9f310..28fe544d93a 100644 --- a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp +++ b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp @@ -164,7 +164,7 @@ verifyResult(const FakeResult &expect, EXPECT_EQUAL(expect.inspect().size(), result->getState().estimate().estHits); EXPECT_EQUAL(expect.inspect().empty(), result->getState().estimate().empty); - result->fetchPostings(true); + result->fetchPostings(true, nullptr); SearchIterator::UP search = result->createSearch(*match_data, true); if (!EXPECT_TRUE(search.get() != 0)) { return false; @@ -432,7 +432,7 @@ TEST("requireThatWeCanFakeBitVector") Blueprint::UP res = searchable.createBlueprint(requestContext, fields, makeTerm(foo)); EXPECT_TRUE(res.get() != NULL); - res->fetchPostings(true); + res->fetchPostings(true, nullptr); SearchIterator::UP search = res->createSearch(*match_data, true); EXPECT_TRUE(search.get() != NULL); EXPECT_TRUE(dynamic_cast(search.get()) != NULL); diff --git a/searchlib/src/tests/nearsearch/nearsearch_test.cpp b/searchlib/src/tests/nearsearch/nearsearch_test.cpp index ce4864a4326..e7bc95e827e 100644 --- a/searchlib/src/tests/nearsearch/nearsearch_test.cpp +++ b/searchlib/src/tests/nearsearch/nearsearch_test.cpp @@ -230,7 +230,7 @@ Test::testNearSearch(MyQuery &query, uint32_t matchId) } search::fef::MatchData::UP md(layout.createMatchData()); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); search::queryeval::SearchIterator::UP near = bp->createSearch(*md, true); near->initFullRange(); bool foundMatch = false; diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp index e5ee83507ae..309ebef9bad 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -186,7 +186,7 @@ public: SearchIterator::UP Test::create(const Blueprint &blueprint) { - const_cast(blueprint).fetchPostings(true); + const_cast(blueprint).fetchPostings(true, nullptr); SearchIterator::UP search = blueprint.createSearch(*_md, true); MySearch::verifyAndInfer(search.get(), *_md); return search; diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp index a97e817b28f..1d6ddeef777 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -1047,7 +1047,7 @@ TEST("test WeakAnd Blueprint") { wa.addTerm(Blueprint::UP(new FakeBlueprint(field, z)), 140); wa.addTerm(Blueprint::UP(new FakeBlueprint(field, y)), 130); { - wa.fetchPostings(true); + wa.fetchPostings(true, nullptr); SearchIterator::UP search = wa.createSearch(*md, true); EXPECT_TRUE(dynamic_cast(search.get()) != 0); WeakAndSearch &s = dynamic_cast(*search); @@ -1069,7 +1069,7 @@ TEST("test WeakAnd Blueprint") { EXPECT_EQUAL(0u, terms[2].maxScore); // NB: not set } { - wa.fetchPostings(false); + wa.fetchPostings(false, nullptr); SearchIterator::UP search = wa.createSearch(*md, false); EXPECT_TRUE(dynamic_cast(search.get()) != 0); EXPECT_TRUE(search->seek(1)); @@ -1099,7 +1099,7 @@ TEST("require_that_unpack_of_or_over_multisearch_is_optimized") { addChild(std::move(child1)). addChild(std::move(child2)))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); EXPECT_EQUAL("search::queryeval::OrLikeSearch", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1125,7 +1125,7 @@ TEST("require_that_unpack_of_or_is_optimized") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); EXPECT_EQUAL("search::queryeval::OrLikeSearch", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1144,7 +1144,7 @@ TEST("require_that_unpack_of_and_is_optimized") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1164,7 +1164,7 @@ TEST("require_that_unpack_optimization_is_honoured_by_parents") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1213,7 +1213,7 @@ TEST("require that children does not optimize when parents refuse them to") { FieldSpec("f2", 2, idxth21), makeTerm("w2")), 1.0))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); SearchIterator::UP search = top_up->createSearch(*md, true); EXPECT_EQUAL("search::queryeval::EquivImpl", search->getClassName()); { @@ -1251,7 +1251,7 @@ TEST("require_that_unpack_optimization_is_overruled_by_equiv") { addChild(ap(MyLeafSpec(10).addField(3,idxth3).create()))), 1.0))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(false, nullptr); SearchIterator::UP search = top_up->createSearch(*md, true); EXPECT_EQUAL("search::queryeval::EquivImpl", search->getClassName()); { diff --git a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp index 2209ab0bfec..49e9a657f26 100644 --- a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp @@ -27,7 +27,7 @@ Test::testEmptyBlueprint() EXPECT_EQUAL(1u, empty.getState().field(0).getFieldId()); EXPECT_EQUAL(11u, empty.getState().field(0).getHandle()); - empty.fetchPostings(true); + empty.fetchPostings(true, nullptr); SearchIterator::UP search = empty.createSearch(*md, true); SimpleResult res; @@ -45,7 +45,7 @@ Test::testSimpleBlueprint() SimpleBlueprint simple(a); simple.tag("tag"); EXPECT_EQUAL("tag", simple.tag()); - simple.fetchPostings(true); + simple.fetchPostings(true, nullptr); SearchIterator::UP search = simple.createSearch(*md, true); SimpleResult res; @@ -67,7 +67,7 @@ Test::testFakeBlueprint() TermFieldHandle handle = 0; FakeBlueprint orig(FieldSpec("", fieldId, handle), fake); - orig.fetchPostings(true); + orig.fetchPostings(true, nullptr); SearchIterator::UP search = orig.createSearch(*md, true); search->initFullRange(); EXPECT_TRUE(!search->seek(1u)); diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h index c47014e1e77..95a94ebdf6c 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -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 #include +#include #include namespace search::queryeval { diff --git a/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp b/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp index f1b6cd05772..8a1be9848dc 100644 --- a/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp +++ b/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp @@ -58,7 +58,7 @@ struct DP { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP sb = bp->createSearch(*md, strict); EXPECT_TRUE(dynamic_cast(sb.get()) != 0); sb->initFullRange(); diff --git a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp index 5dac26fec22..0d7427e9692 100644 --- a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp +++ b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp @@ -50,7 +50,7 @@ Test::testEquiv() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); diff --git a/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp b/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp index 661ca9c2ba3..4b2ca202270 100644 --- a/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp +++ b/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp @@ -79,7 +79,7 @@ Test::testTerm() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -133,7 +133,7 @@ Test::testPhrase() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -189,7 +189,7 @@ Test::testWeightedSet() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -265,7 +265,7 @@ Test::testMultiField() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -354,7 +354,7 @@ Test::testPhraseWithEmptyChild() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); diff --git a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp index 0de450bdff7..8a76f805f40 100644 --- a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp +++ b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp @@ -175,7 +175,7 @@ struct WandBlueprintSpec Node::UP term = createNode(); Blueprint::UP bp = blueprint(searchable, field, *term); MatchData::UP md(MatchData::makeTestInstance(1, 1)); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); bp->setDocIdLimit(docIdLimit); SearchIterator::UP sb = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast(sb.get()) != 0); @@ -190,7 +190,7 @@ struct WandBlueprintSpec FakeResult search(Searchable &searchable, const std::string &field, const search::query::Node &term) const { Blueprint::UP bp = blueprint(searchable, field, term); MatchData::UP md(MatchData::makeTestInstance(1, 1)); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); bp->setDocIdLimit(docIdLimit); SearchIterator::UP sb = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast(sb.get()) != 0); diff --git a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp index d790a6dd17d..0f2cb780cab 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp @@ -138,7 +138,7 @@ TEST_F("require that blueprint can create search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(true, nullptr); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -162,7 +162,7 @@ TEST_F("require that blueprint can create more advanced search", Fixture) { f.indexEmptyDocument(doc_id + 2); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(true, nullptr); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -186,7 +186,7 @@ TEST_F("require that blueprint can create NOT search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(true, nullptr); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -203,7 +203,7 @@ TEST_F("require that blueprint can create compressed NOT search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(true, nullptr); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -227,7 +227,7 @@ TEST_F("require that blueprint can set up search with subqueries", Fixture) { query.getTerm()->addFeature("key2", "value", 2); PredicateBlueprint blueprint(f.field, f.guard(), query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(true, nullptr); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); diff --git a/searchlib/src/tests/queryeval/queryeval.cpp b/searchlib/src/tests/queryeval/queryeval.cpp index c6dd6a430cc..3eb4c110fa8 100644 --- a/searchlib/src/tests/queryeval/queryeval.cpp +++ b/searchlib/src/tests/queryeval/queryeval.cpp @@ -222,7 +222,7 @@ TEST("testAnd") { and_b->addChild(Blueprint::UP(new SimpleBlueprint(a))); and_b->addChild(Blueprint::UP(new SimpleBlueprint(b))); Blueprint::UP bp(and_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP and_ab = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast(and_ab.get()) != nullptr); @@ -250,7 +250,7 @@ TEST("testOr") { or_b->addChild(Blueprint::UP(new SimpleBlueprint(a))); or_b->addChild(Blueprint::UP(new SimpleBlueprint(b))); Blueprint::UP bp(or_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP or_ab = bp->createSearch(*md, true); SimpleResult res; @@ -365,7 +365,7 @@ TEST("testAndNot") { andnot_b->addChild(Blueprint::UP(new SimpleBlueprint(a))); andnot_b->addChild(Blueprint::UP(new SimpleBlueprint(b))); Blueprint::UP bp(andnot_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP andnot_ab = bp->createSearch(*md, true); SimpleResult res; @@ -386,7 +386,7 @@ TEST("testAndNot") { andnot_b->addChild(Blueprint::UP(new SimpleBlueprint(a))); andnot_b->addChild(Blueprint::UP(new DummySingleValueBitNumericAttributeBlueprint(b))); Blueprint::UP bp(andnot_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP andnot_ab = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast(andnot_ab.get()) != NULL); @@ -414,7 +414,7 @@ TEST("testAndNot") { and_b->addChild(Blueprint::UP(new SimpleBlueprint(c))); and_b->addChild(Blueprint::UP(andnot_b)); Blueprint::UP bp(and_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP and_cab = bp->createSearch(*md, true); SimpleResult res; @@ -440,7 +440,7 @@ TEST("testRank") { rank_b->addChild(Blueprint::UP(new SimpleBlueprint(a))); rank_b->addChild(Blueprint::UP(new SimpleBlueprint(b))); Blueprint::UP bp(rank_b); - bp->fetchPostings(true); + bp->fetchPostings(true, nullptr); SearchIterator::UP rank_ab = bp->createSearch(*md, true); SimpleResult res; diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index 765820b53e5..5347c069c52 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -144,11 +144,11 @@ public: fetchPostings(bool useBlueprint) { if (useBlueprint) { - _phrase.fetchPostings(_strict); + _phrase.fetchPostings(_strict, nullptr); return; } for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->fetchPostings(_strict); + _children[i]->fetchPostings(_strict, nullptr); } } diff --git a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp index 2cd687ab23a..e9352546f10 100644 --- a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp +++ b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp @@ -73,7 +73,7 @@ TEST("test strictness") { blend_b->addChild(std::move(a_b)); blend_b->addChild(std::move(b_b)); Blueprint::UP bp(blend_b); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); SearchIterator &blend = *search; diff --git a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp index 78195f19427..1dfbd7729f5 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp +++ b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp @@ -66,7 +66,7 @@ struct WS { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP sb = bp->createSearch(*md, strict); return (dynamic_cast(sb.get()) != 0); } @@ -77,7 +77,7 @@ struct WS { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(strict, nullptr); SearchIterator::UP sb = bp->createSearch(*md, strict); sb->initFullRange(); FakeResult result; @@ -106,11 +106,11 @@ struct MockSearch : public SearchIterator { SearchIterator::initRange(begin, end); setDocId(_initial); } - virtual void doSeek(uint32_t) override { + void doSeek(uint32_t) override { ++seekCnt; setAtEnd(); } - virtual void doUnpack(uint32_t) override {} + void doUnpack(uint32_t) override {} }; struct MockFixture { diff --git a/searchlib/src/vespa/searchlib/attribute/attribute.h b/searchlib/src/vespa/searchlib/attribute/attribute.h index d870ef18034..ce0ffd81340 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/attribute.h @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include -#include -#include -#include +#include "attributevector.h" +#include "integerbase.h" +#include "floatbase.h" +#include "stringbase.h" diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 60b8b1603c8..8c1cb4a0451 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -129,8 +129,8 @@ public: return _search_context->createIterator(tfmda[0], strict); } - void fetchPostings(bool strict) override { - _search_context->fetchPostings(strict); + void fetchPostings(bool strict, const BitVector * filter) override { + _search_context->fetchPostings(strict, filter); } void visitMembers(vespalib::ObjectVisitor &visitor) const override; @@ -206,9 +206,9 @@ public: } } - virtual void fetchPostings(bool strict) override { + virtual void fetchPostings(bool strict, const BitVector * filter) override { for (size_t i(0); i < _rangeSearches.size(); i++) { - _rangeSearches[i]->fetchPostings(strict); + _rangeSearches[i]->fetchPostings(strict, filter); } } }; diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp index 3ff7db5a184..8590c6bf451 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp @@ -184,11 +184,11 @@ AttributeWeightedSetBlueprint::createLeafSearch(const fef::TermFieldMatchDataArr } void -AttributeWeightedSetBlueprint::fetchPostings(bool strict) +AttributeWeightedSetBlueprint::fetchPostings(bool strict, const BitVector * filter) { if (strict) { for (size_t i = 0; i < _contexts.size(); ++i) { - _contexts[i]->fetchPostings(true); + _contexts[i]->fetchPostings(true, filter); } } } diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h index 3b4bbd2d916..b238023559c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h @@ -30,7 +30,7 @@ public: ~AttributeWeightedSetBlueprint(); void addToken(std::unique_ptr context, int32_t weight); queryeval::SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 5261eb0bb05..8a8824c0e54 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -73,7 +73,7 @@ AttributeVector::BaseName::BaseName(const vespalib::stringref &base, append(name); } -AttributeVector::BaseName::~BaseName() { } +AttributeVector::BaseName::~BaseName() = default; AttributeVector::BaseName::string @@ -183,7 +183,7 @@ AttributeVector::AttributeVector(const vespalib::stringref &baseFileName, const { } -AttributeVector::~AttributeVector() { } +AttributeVector::~AttributeVector() = default; void AttributeVector::updateStat(bool force) { if (force) { @@ -585,7 +585,7 @@ AttributeVector::createSearchContext(QueryTermSimpleUP term, return getSearch(std::move(term), params); } -AttributeVector::SearchContext::~SearchContext() { } +AttributeVector::SearchContext::~SearchContext() = default; unsigned int AttributeVector::SearchContext::approximateHits() const @@ -633,9 +633,10 @@ createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) void -AttributeVector::SearchContext::fetchPostings(bool strict) { - if (_plsc != NULL) - _plsc->fetchPostings(strict); +AttributeVector::SearchContext::fetchPostings(bool strict, const BitVector * filter) { + if (_plsc != nullptr) { + _plsc->fetchPostings(strict, filter); + } } @@ -645,8 +646,7 @@ AttributeVector::apply(DocId doc, const MapValueUpdate &map) { if (retval) { const ValueUpdate & vu(map.getUpdate()); if (vu.inherits(ArithmeticValueUpdate::classId)) { - const ArithmeticValueUpdate & - au(static_cast(vu)); + const ArithmeticValueUpdate &au(static_cast(vu)); retval = applyWeight(doc, map.getKey(), au); } else { retval = false; diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 470e612770d..3fbcc9f7ca3 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -540,15 +540,15 @@ public: ~SearchContext(); // Implements attribute::ISearchContext - virtual unsigned int approximateHits() const override; - virtual queryeval::SearchIterator::UP createIterator(fef::TermFieldMatchData *matchData, bool strict) override; - virtual void fetchPostings(bool strict) override; - virtual bool valid() const override { return false; } - virtual Int64Range getAsIntegerTerm() const override { return Int64Range(); } - virtual const QueryTermBase &queryTerm() const override { + unsigned int approximateHits() const override; + queryeval::SearchIterator::UP createIterator(fef::TermFieldMatchData *matchData, bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; + bool valid() const override { return false; } + Int64Range getAsIntegerTerm() const override { return Int64Range(); } + const QueryTermBase &queryTerm() const override { return *static_cast(NULL); } - virtual const vespalib::string &attributeName() const override { + const vespalib::string &attributeName() const override { return _attr.getName(); } @@ -570,8 +570,8 @@ public: }; SearchContext::UP getSearch(QueryPacketT searchSpec, const attribute::SearchContextParams ¶ms) const; - virtual attribute::ISearchContext::UP createSearchContext(QueryTermSimpleUP term, - const attribute::SearchContextParams ¶ms) const override; + attribute::ISearchContext::UP createSearchContext(QueryTermSimpleUP term, + const attribute::SearchContextParams ¶ms) const override; virtual SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams ¶ms) const = 0; virtual const EnumStoreBase *getEnumStoreBase() const; virtual const attribute::MultiValueMappingBase *getMultiValueBase() const; @@ -662,15 +662,15 @@ public: bool hasPostings(); virtual uint64_t getUniqueValueCount() const; virtual uint64_t getTotalValueCount() const; - virtual void compactLidSpace(uint32_t wantedLidLimit) override; + void compactLidSpace(uint32_t wantedLidLimit) override; virtual void clearDocs(DocId lidLow, DocId lidLimit); bool wantShrinkLidSpace() const { return _committedDocIdLimit < getNumDocs(); } - virtual bool canShrinkLidSpace() const override; - virtual void shrinkLidSpace() override; + bool canShrinkLidSpace() const override; + void shrinkLidSpace() override; virtual void onShrinkLidSpace(); - virtual size_t getEstimatedShrinkLidSpaceGain() const override; + size_t getEstimatedShrinkLidSpaceGain() const override; - virtual std::unique_ptr makeReadGuard(bool stableEnumGuard) const override; + std::unique_ptr makeReadGuard(bool stableEnumGuard) const override; void setInterlock(const std::shared_ptr &interlock); diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.h b/searchlib/src/vespa/searchlib/attribute/diversity.h index dff658d99d7..fe2874a65a1 100644 --- a/searchlib/src/vespa/searchlib/attribute/diversity.h +++ b/searchlib/src/vespa/searchlib/attribute/diversity.h @@ -14,9 +14,7 @@ * diversified results based on a secondary attribute. **/ -namespace search { -namespace attribute { -namespace diversity { +namespace search::attribute::diversity { template class ForwardRange @@ -227,6 +225,4 @@ void diversify(bool forward, const DictItr &lower, const DictItr &upper, const P } } -} // namespace search::attribute::diversity -} // namespace search::attribute -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.hpp b/searchlib/src/vespa/searchlib/attribute/diversity.hpp index 9261bb482f9..698f482dec1 100644 --- a/searchlib/src/vespa/searchlib/attribute/diversity.hpp +++ b/searchlib/src/vespa/searchlib/attribute/diversity.hpp @@ -4,9 +4,7 @@ #include "diversity.h" -namespace search { -namespace attribute { -namespace diversity { +namespace search::attribute::diversity { template ForwardRange::ForwardRange(const ForwardRange &) = default; @@ -18,7 +16,7 @@ ForwardRange::ForwardRange(const ITR &lower, const ITR &upper) {} template -ForwardRange::~ForwardRange() { } +ForwardRange::~ForwardRange() = default; template ReverseRange::ReverseRange(const ReverseRange &) = default; @@ -31,8 +29,6 @@ ReverseRange::ReverseRange(const ITR &lower, const ITR &upper) template -ReverseRange::~ReverseRange() { } +ReverseRange::~ReverseRange() = default; } -} -} diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp index 7cad3f7d1d3..088be3f5f47 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp @@ -3,12 +3,10 @@ #include "enumhintsearchcontext.h" #include -namespace search { +namespace search::attribute { using queryeval::SearchIterator; -namespace attribute { - using btree::BTreeNode; using fef::TermFieldMatchData; @@ -25,9 +23,7 @@ EnumHintSearchContext(const EnumStoreDictBase &dictionary, } -EnumHintSearchContext::~EnumHintSearchContext() -{ -} +EnumHintSearchContext::~EnumHintSearchContext() = default; void @@ -38,21 +34,20 @@ EnumHintSearchContext::lookupTerm(const EnumStoreComparator &comp) void -EnumHintSearchContext::lookupRange(const EnumStoreComparator &low, - const EnumStoreComparator &high) +EnumHintSearchContext::lookupRange(const EnumStoreComparator &low, const EnumStoreComparator &high) { _uniqueValues = _dictionary.lookupFrozenRange(_frozenRootRef, low, high); } void -EnumHintSearchContext::fetchPostings(bool strict) +EnumHintSearchContext::fetchPostings(bool strict, const BitVector * filter) { (void) strict; + (void) filter; } SearchIterator::UP -EnumHintSearchContext::createPostingIterator(TermFieldMatchData *matchData, - bool strict) +EnumHintSearchContext::createPostingIterator(TermFieldMatchData *matchData, bool strict) { (void) matchData; (void) strict; @@ -71,6 +66,4 @@ EnumHintSearchContext::approximateHits() const : std::max(uint64_t(_docIdLimit), _numValues); } -} // namespace attribute - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h index be315b05a69..fe8b84879b4 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h @@ -7,11 +7,7 @@ #include "ipostinglistsearchcontext.h" #include -namespace search -{ - -namespace attribute -{ +namespace search::attribute { /** * Search context helper for enumerated attributes, used to eliminate @@ -38,12 +34,8 @@ protected: queryeval::SearchIterator::UP createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; unsigned int approximateHits() const override; }; - -} // namespace attribute - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp index bfcd7f29f29..8b60d02a457 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp @@ -44,8 +44,7 @@ ImportedSearchContext::ImportedSearchContext( } -ImportedSearchContext::~ImportedSearchContext() { -} +ImportedSearchContext::~ImportedSearchContext() = default; unsigned int ImportedSearchContext::approximateHits() const { return _reference_attribute.getNumDocs(); @@ -227,11 +226,11 @@ ImportedSearchContext::considerAddSearchCacheEntry() } } -void ImportedSearchContext::fetchPostings(bool strict) { +void ImportedSearchContext::fetchPostings(bool strict, const BitVector * filter) { assert(!_fetchPostingsDone); _fetchPostingsDone = true; if (!_searchCacheLookup) { - _target_search_context->fetchPostings(strict); + _target_search_context->fetchPostings(strict, filter); if (strict || _target_attribute.getIsFastSearch()) { makeMergedPostings(_target_attribute.getIsFilter()); considerAddSearchCacheEntry(); diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h index f8b434d4c6c..eb467a925c2 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h @@ -56,7 +56,7 @@ public: std::unique_ptr createIterator(fef::TermFieldMatchData* matchData, bool strict) override; unsigned int approximateHits() const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; bool valid() const override; Int64Range getAsIntegerTerm() const override; const QueryTermBase& queryTerm() const override; diff --git a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h index e779e41bb90..b47de1b7e32 100644 --- a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h @@ -4,12 +4,11 @@ #include -namespace search { +namespace search::queryeval { class SearchIterator; } +namespace search::fef { class TermFieldMatchData; } +namespace search { class BitVector; } -namespace queryeval { class SearchIterator; } -namespace fef { class TermFieldMatchData; } - -namespace attribute { +namespace search::attribute { /** @@ -27,10 +26,14 @@ protected: virtual ~IPostingListSearchContext() { } public: - virtual void fetchPostings(bool strict) = 0; + /** + * Will load/prepare any postings lists. Will take strictness and optional filter into account. + * @param strict If true iterator must advance to next valid docid. + * @param filter Any prefilter that can be applied to posting lists for optimization purposes. + */ + virtual void fetchPostings(bool strict, const BitVector * filter) = 0; virtual std::unique_ptr createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) = 0; virtual unsigned int approximateHits() const = 0; }; -} // namespace attribute -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h index 5bf232cf01f..9d3a17193d8 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h @@ -119,7 +119,7 @@ protected: void fillArray(); void fillBitVector(); - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; // this will be called instead of the fetchPostings function in some cases void diversify(bool forward, size_t wanted_hits, const IAttributeVector &diversity_attr, size_t max_per_group, size_t cutoff_groups, bool cutoff_strict); @@ -224,7 +224,7 @@ private: ? limit : estimate; } - void fetchPostings(bool strict) override { + void fetchPostings(bool strict, const BitVector * filter) override { if (params().diversityAttribute() != nullptr) { bool forward = (this->getRangeLimit() > 0); size_t wanted_hits = std::abs(this->getRangeLimit()); @@ -232,7 +232,7 @@ private: *(params().diversityAttribute()), this->getMaxPerGroup(), params().diversityCutoffGroups(), params().diversityCutoffStrict()); } else { - PostingListSearchContextT::fetchPostings(strict); + PostingListSearchContextT::fetchPostings(strict, filter); } } @@ -261,7 +261,7 @@ PostingSearchContext(QueryTermSimpleUP qTerm, bool useBitVector, const AttrT &to } template -PostingSearchContext::~PostingSearchContext() { } +PostingSearchContext::~PostingSearchContext() = default; template diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp index 48f9d0404c5..3306f6147df 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp @@ -30,7 +30,7 @@ PostingListSearchContextT(const Dictionary &dictionary, uint32_t docIdLimit, uin } template -PostingListSearchContextT::~PostingListSearchContextT() {} +PostingListSearchContextT::~PostingListSearchContextT() = default; template @@ -111,8 +111,9 @@ PostingListSearchContextT::fillBitVector() template void -PostingListSearchContextT::fetchPostings(bool strict) +PostingListSearchContextT::fetchPostings(bool strict, const BitVector * filter) { + (void) filter; assert(!_fetchPostingsDone); _fetchPostingsDone = true; if (_uniqueValues < 2u) { diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp index e2c3dafc13d..24fd5425a89 100644 --- a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp @@ -56,9 +56,9 @@ namespace { bool areAnyParentsEquiv(const Blueprint * node) { - return (node == NULL) + return (node == nullptr) ? false - : (dynamic_cast(node) != NULL) + : (dynamic_cast(node) != nullptr) ? true : areAnyParentsEquiv(node->getParent()); } @@ -66,12 +66,13 @@ areAnyParentsEquiv(const Blueprint * node) } void -DiskTermBlueprint::fetchPostings(bool strict) +DiskTermBlueprint::fetchPostings(bool strict, const BitVector * filter) { (void) strict; + (void) filter; _hasEquivParent = areAnyParentsEquiv(getParent()); _bitVector = _diskIndex.readBitVector(*_lookupRes); - if (!_useBitVector || (_bitVector.get() == NULL)) { + if (!_useBitVector || (_bitVector.get() == nullptr)) { _postingHandle = _diskIndex.readPostingList(*_lookupRes); } _fetchPostingsDone = true; diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h index f7806235533..30e8f55b5b7 100644 --- a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h +++ b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h @@ -40,7 +40,7 @@ public: // For now, this DiskTermBlueprint instance must have longer lifetime than the created iterator. std::unique_ptr createLeafSearch(const fef::TermFieldMatchDataArray & tfmda, bool strict) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index f9b8a9437dc..9a9b1818f04 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -4,6 +4,7 @@ #include "leaf_blueprints.h" #include "intermediate_blueprints.h" #include "equiv_blueprint.h" +#include #include #include #include @@ -69,7 +70,7 @@ Blueprint::State::State(const FieldSpecBaseList &fields_in) { } -Blueprint::State::~State() { } +Blueprint::State::~State() = default; Blueprint::Blueprint() : _parent(0), @@ -79,9 +80,7 @@ Blueprint::Blueprint() { } -Blueprint::~Blueprint() -{ -} +Blueprint::~Blueprint() = default; Blueprint::UP Blueprint::optimize(Blueprint::UP bp) { @@ -385,11 +384,11 @@ IntermediateBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const } void -IntermediateBlueprint::fetchPostings(bool strict) +IntermediateBlueprint::fetchPostings(bool strict, const BitVector * filter) { for (size_t i = 0; i < _children.size(); ++i) { bool strictChild = (strict && inheritStrict(i)); - _children[i]->fetchPostings(strictChild); + _children[i]->fetchPostings(strictChild, filter); } } @@ -469,12 +468,11 @@ LeafBlueprint::LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwis _state.allow_termwise_eval(allow_termwise_eval); } -LeafBlueprint::~LeafBlueprint() { } +LeafBlueprint::~LeafBlueprint() = default; void -LeafBlueprint::fetchPostings(bool strict) +LeafBlueprint::fetchPostings(bool, const BitVector *) { - (void) strict; } void diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index d9033693371..e4c9f2e2a53 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -4,12 +4,13 @@ #include "field_spec.h" #include "unpackinfo.h" -#include -#include -#include -#include -namespace vespalib { class ObjectVisitor; }; +namespace vespalib { class ObjectVisitor; } +namespace search { class BitVector; } +namespace search::fef { + class TermFieldMatchDataArray; + class MatchData; +} namespace search::queryeval { @@ -165,7 +166,12 @@ public: double hit_ratio() const { return getState().hit_ratio(_docid_limit); } - virtual void fetchPostings(bool strict) = 0; + /** + * Will load/prepare any postings lists. Will take strictness and optional filter into account. + * @param strict If true iterators produced must advance to next valid docid. + * @param filter Any prefilter that can be applied to posting lists for optimization purposes. + */ + virtual void fetchPostings(bool strict, const BitVector * filter) = 0; virtual void freeze() = 0; bool frozen() const { return _frozen; } @@ -264,7 +270,7 @@ public: bool strict, fef::MatchData &md) const = 0; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; void freeze() override final; UnpackInfo calculateUnpackInfo(const fef::MatchData & md) const; @@ -288,12 +294,11 @@ public: ~LeafBlueprint(); const State &getState() const override final { return _state; } void setDocIdLimit(uint32_t limit) override final { Blueprint::setDocIdLimit(limit); } - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; void freeze() override final; SearchIteratorUP createSearch(fef::MatchData &md, bool strict) const override; - virtual SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, - bool strict) const = 0; + virtual SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const = 0; }; // for leaf nodes representing a single term diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp index f76cd0d6acc..9b17857d3a0 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp @@ -64,11 +64,11 @@ DotProductBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray } void -DotProductBlueprint::fetchPostings(bool strict) +DotProductBlueprint::fetchPostings(bool strict, const BitVector * filter) { (void) strict; for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(true); + _terms[i]->fetchPostings(true, filter); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h index e19a6cdb7f9..5155ed6e581 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h @@ -30,11 +30,10 @@ public: void addTerm(Blueprint::UP term, int32_t weight); SearchIteratorUP - createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, - bool strict) const override; + createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp index bdd64f4c938..9d12a5c652f 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp @@ -4,8 +4,7 @@ #include "equivsearch.h" #include -namespace search { -namespace queryeval { +namespace search::queryeval { EquivBlueprint::EquivBlueprint(const FieldSpecBaseList &fields, fef::MatchDataLayout subtree_mdl) @@ -18,9 +17,7 @@ EquivBlueprint::EquivBlueprint(const FieldSpecBaseList &fields, { } -EquivBlueprint::~EquivBlueprint() -{ -} +EquivBlueprint::~EquivBlueprint() = default; SearchIterator::UP EquivBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray &outputs, @@ -47,10 +44,10 @@ EquivBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const } void -EquivBlueprint::fetchPostings(bool strict) +EquivBlueprint::fetchPostings(bool strict, const BitVector * filter) { for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(strict); + _terms[i]->fetchPostings(strict, filter); } } @@ -70,5 +67,4 @@ EquivBlueprint::addTerm(Blueprint::UP term, double exactness) } -} // namespace queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h index 09a41ab13df..47442c131fd 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h @@ -5,8 +5,7 @@ #include "blueprint.h" #include -namespace search { -namespace queryeval { +namespace search::queryeval { class EquivBlueprint : public ComplexLeafBlueprint { @@ -19,7 +18,7 @@ private: public: EquivBlueprint(const FieldSpecBaseList &fields, fef::MatchDataLayout subtree_mdl); - virtual ~EquivBlueprint(); + ~EquivBlueprint(); // used by create visitor EquivBlueprint& addTerm(Blueprint::UP term, double exactness); @@ -27,9 +26,8 @@ public: SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; bool isEquiv() const override { return true; } }; -} // namespace queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp index a119823c0dd..24848da1db6 100644 --- a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp @@ -20,8 +20,7 @@ using std::vector; using vespalib::string; using namespace search::predicate; -namespace search { -namespace queryeval { +namespace search::queryeval { namespace { typedef PredicateBlueprint::IntervalEntry IntervalEntry; @@ -204,7 +203,7 @@ PredicateBlueprint::PredicateBlueprint(const FieldSpecBase &field, } } -PredicateBlueprint::~PredicateBlueprint() {} +PredicateBlueprint::~PredicateBlueprint() = default; namespace { @@ -228,7 +227,7 @@ namespace { } -void PredicateBlueprint::fetchPostings(bool) { +void PredicateBlueprint::fetchPostings(bool, const BitVector *) { const auto &interval_index = _index.getIntervalIndex(); const auto &bounds_index = _index.getBoundsIndex(); lookupPostingLists(_interval_dict_entries, _interval_vector_iterators, @@ -339,5 +338,5 @@ std::vector PredicateBlueprint::createPostingLists() c } return posting_lists; } -} // namespace search::queryeval -} // namespace search + +} diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h index af279446307..e258c72e98f 100644 --- a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h @@ -10,10 +10,9 @@ #include #include -namespace search { -namespace query { class PredicateQuery; } +namespace search::query { class PredicateQuery; } -namespace queryeval { +namespace search::queryeval { /** * Blueprint for building predicate searches. It builds search * iterators based on PredicateSearch. @@ -49,11 +48,10 @@ public: const query::PredicateQuery &query); ~PredicateBlueprint(); - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; SearchIterator::UP - createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, - bool strict) const override; + createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; private: using BTreeIterator = predicate::SimpleIndex::BTreeIterator; using VectorIterator = predicate::SimpleIndex::VectorIterator; @@ -91,6 +89,4 @@ private: optional _zstar_vector_iterator; }; -} // namespace search::queryeval -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp index 5dbe59f8da0..6c35f42542f 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp @@ -7,8 +7,7 @@ #include #include -namespace search { -namespace queryeval { +namespace search::queryeval { SimplePhraseBlueprint::SimplePhraseBlueprint(const FieldSpec &field, const IRequestContext & requestContext) : ComplexLeafBlueprint(field), @@ -82,10 +81,10 @@ SimplePhraseBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArr void -SimplePhraseBlueprint::fetchPostings(bool strict) +SimplePhraseBlueprint::fetchPostings(bool strict, const BitVector * filter) { for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(strict); + _terms[i]->fetchPostings(strict, filter); } } @@ -96,5 +95,4 @@ SimplePhraseBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const visit(visitor, "terms", _terms); } -} // namespace search::queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h index d0e3868f34a..2d19a23fdab 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h @@ -32,11 +32,9 @@ public: // used by create visitor void addTerm(Blueprint::UP term); - SearchIteratorUP - createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, - bool strict) const override; + SearchIteratorUP createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp index 1ae52131c3c..8d1221919dd 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp @@ -7,8 +7,7 @@ #include #include -namespace search { -namespace queryeval { +namespace search::queryeval { ParallelWeakAndBlueprint::ParallelWeakAndBlueprint(const FieldSpec &field, uint32_t scoresToTrack, @@ -103,10 +102,10 @@ ParallelWeakAndBlueprint::createLeafSearch(const search::fef::TermFieldMatchData } void -ParallelWeakAndBlueprint::fetchPostings(bool) +ParallelWeakAndBlueprint::fetchPostings(bool, const BitVector * filter) { for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(true); + _terms[i]->fetchPostings(true, filter); } } @@ -118,5 +117,4 @@ ParallelWeakAndBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const visit(visitor, "_terms", _terms); } -} // namespace search::queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h index 9ce4e618fcf..53c2bf99aed 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h @@ -9,8 +9,7 @@ #include #include -namespace search { -namespace queryeval { +namespace search::queryeval { const uint32_t DEFAULT_PARALLEL_WAND_SCORES_ADJUST_FREQUENCY = 4; @@ -61,9 +60,7 @@ public: SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; -} // namespace queryeval -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp index fc68c48a247..f25cac9a2a2 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp @@ -57,11 +57,11 @@ WeightedSetTermBlueprint::createLeafSearch(const search::fef::TermFieldMatchData } void -WeightedSetTermBlueprint::fetchPostings(bool strict) +WeightedSetTermBlueprint::fetchPostings(bool strict, const BitVector * filter) { (void) strict; for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(true); + _terms[i]->fetchPostings(true, filter); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h index 19e88466b1a..6f5ac1038f4 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h @@ -37,7 +37,7 @@ public: void visitMembers(vespalib::ObjectVisitor &visitor) const override; private: - void fetchPostings(bool strict) override; + void fetchPostings(bool strict, const BitVector * filter) override; }; } -- cgit v1.2.3