diff options
author | Arnstein Ressem <aressem@gmail.com> | 2020-01-03 09:31:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-03 09:31:32 +0100 |
commit | 5a89acb50b5c67b97f4039cf972808a6505ebd81 (patch) | |
tree | 6ff7626bc1ee78ae4d0361a6572b6eb16b61ba4e | |
parent | 4bbac8adbf1d9e0f112f950323e5ca08eb6ba658 (diff) |
Revert "Balder/add executeinfo"
103 files changed, 434 insertions, 605 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h index 795129bf3b8..9a24ab82c9f 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h +++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h @@ -6,10 +6,7 @@ #include <vespa/vespalib/stllike/string.h> namespace search::fef { class TermFieldMatchData; } -namespace search::queryeval { - class SearchIterator; - class ExecuteInfo; -} +namespace search::queryeval { class SearchIterator; } namespace search { class QueryTermUCS4; } namespace search::attribute { @@ -46,7 +43,7 @@ public: * Create temporary posting lists. * Should be called before createIterator() is called. */ - virtual void fetchPostings(const queryeval::ExecuteInfo &execInfo) = 0; + virtual void fetchPostings(bool strict) = 0; virtual bool valid() const = 0; virtual Int64Range getAsIntegerTerm() const = 0; diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index f8069dcf494..4dbc6be57ff 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -193,7 +193,7 @@ assertWhiteList(const SimpleResult &exp, Blueprint::UP whiteListBlueprint, bool { MatchDataLayout mdl; MatchData::UP md = mdl.createMatchData(); - whiteListBlueprint->fetchPostings(search::queryeval::ExecuteInfo::create(strict)); + whiteListBlueprint->fetchPostings(strict); 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 ca45108b698..4580865b3a4 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 @@ -125,7 +125,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(search::queryeval::ExecuteInfo::TRUE); + result->fetchPostings(true); 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 975061f9d88..49b452aec2e 100644 --- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp +++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp @@ -243,7 +243,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(search::queryeval::ExecuteInfo::TRUE); + blueprint->fetchPostings(true); 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 201824cd764..2d0482b0d92 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,7 +4,6 @@ #include <vespa/searchlib/queryeval/termasstring.h> #include <vespa/searchlib/queryeval/andsearchstrict.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/searchlib/engine/trace.h> #include <vespa/vespalib/data/slime/slime.h> @@ -55,7 +54,7 @@ struct MockBlueprint : SimpleLeafBlueprint { FieldSpec spec; vespalib::string term; bool postings_fetched = false; - search::queryeval::ExecuteInfo postings_strict = search::queryeval::ExecuteInfo::FALSE; + bool postings_strict = false; MockBlueprint(const FieldSpec &spec_in, const vespalib::string &term_in) : SimpleLeafBlueprint(FieldSpecBaseList().add(spec_in)), spec(spec_in), term(term_in) { @@ -65,13 +64,13 @@ struct MockBlueprint : SimpleLeafBlueprint { bool strict) const override { if (postings_fetched) { - EXPECT_EQUAL(postings_strict.isStrict(), strict); + EXPECT_EQUAL(postings_strict, strict); } return SearchIterator::UP(new MockSearch(spec, term, strict, tfmda, postings_fetched)); } - virtual void fetchPostings(const search::queryeval::ExecuteInfo &execInfo) override { - postings_strict = execInfo; + virtual void fetchPostings(bool strict) override { + postings_strict = strict; postings_fetched = true; } }; diff --git a/searchcore/src/tests/proton/matching/query_test.cpp b/searchcore/src/tests/proton/matching/query_test.cpp index 96e1eb3cc22..85234ea9725 100644 --- a/searchcore/src/tests/proton/matching/query_test.cpp +++ b/searchcore/src/tests/proton/matching/query_test.cpp @@ -69,7 +69,6 @@ using search::queryeval::AndBlueprint; using search::queryeval::IntermediateBlueprint; using search::queryeval::AndNotBlueprint; using search::queryeval::SourceBlenderBlueprint; -using search::queryeval::ExecuteInfo; using std::string; using std::vector; @@ -455,7 +454,7 @@ SearchIterator::UP Test::getIterator(Node &node, ISearchContext &context) { _blueprint = BlueprintBuilder::build(_requestContext, node, context); - _blueprint->fetchPostings(ExecuteInfo::TRUE); + _blueprint->fetchPostings(true); SearchIterator::UP search(_blueprint->createSearch(*_match_data, true)); search->initFullRange(); return search; @@ -822,10 +821,10 @@ Test::requireThatFakeFieldSearchDumpsDiffer() Blueprint::UP l3(a.createBlueprint(requestContext, fields2, n3)); // field Blueprint::UP l4(b.createBlueprint(requestContext, fields1, n1)); // tag - l1->fetchPostings(ExecuteInfo::TRUE); - l2->fetchPostings(ExecuteInfo::TRUE); - l3->fetchPostings(ExecuteInfo::TRUE); - l4->fetchPostings(ExecuteInfo::TRUE); + l1->fetchPostings(true); + l2->fetchPostings(true); + l3->fetchPostings(true); + l4->fetchPostings(true); 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 5d01753dfb6..297f75054b2 100644 --- a/searchcore/src/tests/proton/matching/querynodes_test.cpp +++ b/searchcore/src/tests/proton/matching/querynodes_test.cpp @@ -201,7 +201,7 @@ public: MatchData::UP match_data = mdl.createMatchData(); Blueprint::UP blueprint = BlueprintBuilder::build(requestContext, node, context); - blueprint->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + blueprint->fetchPostings(true); 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 525f4f7a267..94217371af3 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -2,8 +2,6 @@ #include "lid_allocator.h" #include <vespa/searchlib/common/bitvectoriterator.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> -#include <vespa/searchlib/fef/matchdata.h> #include <mutex> #include <vespa/log/log.h> @@ -199,7 +197,7 @@ private: mutable std::mutex _lock; mutable std::vector<search::fef::TermFieldMatchData *> _matchDataVector; - SearchIterator::UP + virtual SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp index a0841295746..d165a18ae37 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp @@ -77,7 +77,7 @@ 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(ExecuteInfo::create(strictSearch)); + _blueprint->fetchPostings(strictSearch); _estimatedHits = _blueprint->getState().estimate().estHits; _blueprint->freeze(); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index b254fd1b4b6..fb9882bf1b1 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -195,7 +195,7 @@ Query::optimize() void Query::fetchPostings() { - _blueprint->fetchPostings(search::queryeval::ExecuteInfo::create(true, 1.0)); + _blueprint->fetchPostings(true); } void diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp index 98e44ff8e44..39f6a489908 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp @@ -219,21 +219,12 @@ WarmupIndexCollection::getSearchableSP(uint32_t i) const return _next->getSearchableSP(i); } -WarmupIndexCollection::WarmupTask::WarmupTask(std::unique_ptr<MatchData> md, WarmupIndexCollection & warmup) - : _warmup(warmup), - _matchData(std::move(md)), - _bluePrint(), - _requestContext() -{ } - -WarmupIndexCollection::WarmupTask::~WarmupTask() = default; - void WarmupIndexCollection::WarmupTask::run() { if (_warmup._warmupEndTime != vespalib::steady_time()) { LOG(debug, "Warming up %s", _bluePrint->asString().c_str()); - _bluePrint->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + _bluePrint->fetchPostings(true); SearchIterator::UP it(_bluePrint->createSearch(*_matchData, true)); it->initFullRange(); for (uint32_t docId = it->seekFirst(1); !it->isAtEnd(); docId = it->seekNext(docId+1)) { diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h index fb36807b8e4..571353574c1 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h @@ -70,8 +70,12 @@ private: typedef vespalib::Executor::Task Task; class WarmupTask : public Task { public: - WarmupTask(std::unique_ptr<MatchData> md, WarmupIndexCollection & warmup); - ~WarmupTask() override; + WarmupTask(MatchData::UP md, WarmupIndexCollection & warmup) : + _warmup(warmup), + _matchData(std::move(md)), + _bluePrint(), + _requestContext() + { } WarmupTask &createBlueprint(const FieldSpec &field, const Node &term) { _bluePrint = _warmup.createBlueprint(_requestContext, field, term); return *this; @@ -82,10 +86,10 @@ private: } private: void run() override; - WarmupIndexCollection & _warmup; - std::unique_ptr<MatchData> _matchData; - Blueprint::UP _bluePrint; - FakeRequestContext _requestContext; + WarmupIndexCollection & _warmup; + MatchData::UP _matchData; + Blueprint::UP _bluePrint; + FakeRequestContext _requestContext; }; void fireWarmup(Task::UP task); diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index a7689cd6b9f..1571cef630b 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -323,9 +323,9 @@ Fixture::readWork(uint32_t cnt) } else { ++nonEmptyCount; } - result->fetchPostings(ExecuteInfo::TRUE); + result->fetchPostings(true); SearchIterator::UP search = result->createSearch(*match_data, true); - if (!EXPECT_TRUE(search)) { + if (!EXPECT_TRUE(search.get() != 0)) { LOG(error, "Did not get search iterator"); break; } @@ -418,7 +418,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(ExecuteInfo::TRUE); + result->fetchPostings(true); 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 bcb70abc654..8ff6ba46e86 100644 --- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -6,7 +6,6 @@ #include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/queryeval/hitcollector.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/compress.h> #include <vespa/searchlib/parsequery/parse.h> @@ -134,7 +133,7 @@ AttributeFindSearcher<T>::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(queryeval::ExecuteInfo::TRUE); + searchContext->fetchPostings(true); std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true); std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -212,7 +211,7 @@ AttributeRangeSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(queryeval::ExecuteInfo::TRUE); + searchContext->fetchPostings(true); std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true); std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -251,7 +250,7 @@ AttributePrefixSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(queryeval::ExecuteInfo::TRUE); + searchContext->fetchPostings(true); std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true); std::unique_ptr<ResultSet> 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 24919fb2341..a8abf1ff4fe 100644 --- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp @@ -17,8 +17,6 @@ #include <vespa/searchlib/parsequery/parse.h> #include <vespa/log/log.h> -#include <vespa/searchlib/queryeval/executeinfo.h> - LOG_SETUP("bitvector_test"); using search::AttributeFactory; @@ -456,7 +454,7 @@ BitVectorTest::checkSearch(AttributePtr v, bool checkStride) { TermFieldMatchData md; - sc->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); checkSearch(v, std::move(sb), md, expFirstDocId, expLastDocId, expDocFreq, weights, diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index bf829f6607a..09cd186811d 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -9,11 +9,11 @@ #include <vespa/searchlib/attribute/attributememoryfilebufferwriter.h> #include <vespa/searchlib/attribute/attributememorysavetarget.h> #include <vespa/searchlib/attribute/attributesaver.h> +#include <vespa/searchlib/attribute/attrvector.h> #include <vespa/searchlib/attribute/multinumericattribute.h> #include <vespa/searchlib/attribute/multistringattribute.h> #include <vespa/searchlib/attribute/singlenumericattribute.h> #include <vespa/searchlib/attribute/singlestringattribute.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/parsequery/parse.h> @@ -29,7 +29,6 @@ #include <cmath> using search::AttributeFactory; -using search::AttributeVector; using search::AttributeMemoryFileBufferWriter; using search::BufferWriter; using search::FloatingPointAttribute; @@ -631,7 +630,7 @@ EnumeratedSaveTest::testReload(AttributePtr v0, TermFieldMatchData md; SearchContextPtr sc = getSearch<VectorType>(as<VectorType>(v)); - sc->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); sb->initFullRange(); sb->seek(1u); diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp index 3a885dda233..7ad3227917b 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -2,6 +2,9 @@ #include <vespa/searchlib/attribute/enumstore.hpp> #include <vespa/vespalib/gtest/gtest.h> +#include <iostream> +#include <limits> +#include <string> #include <vespa/log/log.h> LOG_SETUP("enumstore_test"); diff --git a/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt b/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt index 3421bc34ca5..2d29050aec1 100644 --- a/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt +++ b/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt @@ -4,6 +4,5 @@ vespa_add_executable(searchlib_imported_attribute_vector_test_app TEST imported_attribute_vector_test.cpp DEPENDS searchlib - searchlib_test ) vespa_add_test(NAME searchlib_imported_attribute_vector_test_app COMMAND searchlib_imported_attribute_vector_test_app) diff --git a/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt b/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt index b77671f3c6e..9558d09da85 100644 --- a/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt +++ b/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt @@ -4,6 +4,5 @@ vespa_add_executable(searchlib_imported_search_context_test_app TEST imported_search_context_test.cpp DEPENDS searchlib - searchlib_test ) vespa_add_test(NAME searchlib_imported_search_context_test_app COMMAND searchlib_imported_search_context_test_app) 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 1bc87ef0da5..e8dbaefc2ba 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 @@ -1,13 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchcommon/attribute/search_context_params.h> +#include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/searchlib/attribute/imported_search_context.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/query/query_term_ucs4.h> #include <vespa/searchlib/queryeval/simpleresult.h> #include <vespa/searchlib/test/imported_attribute_fixture.h> #include <vespa/vespalib/test/insertion_operators.h> -#include <vespa/searchlib/queryeval/executeinfo.h> namespace search::attribute { @@ -18,30 +18,31 @@ using vespalib::Trinary; struct Fixture : ImportedAttributeFixture { - Fixture(bool useSearchCache = false, FastSearchConfig fastSearch = FastSearchConfig::Default) - : ImportedAttributeFixture(useSearchCache, fastSearch) - {} + Fixture(bool useSearchCache = false) : ImportedAttributeFixture(useSearchCache) {} - std::unique_ptr<ImportedSearchContext> - create_context(std::unique_ptr<QueryTermSimple> term) { + std::unique_ptr<ImportedSearchContext> create_context(std::unique_ptr<QueryTermSimple> term) { return std::make_unique<ImportedSearchContext>(std::move(term), SearchContextParams(), *imported_attr, *target_attr); } - std::unique_ptr<SearchIterator> - create_iterator(ImportedSearchContext& ctx,TermFieldMatchData& match,bool strict) { + std::unique_ptr<SearchIterator> create_iterator( + ImportedSearchContext& ctx, + TermFieldMatchData& match, + bool strict) { auto iter = ctx.createIterator(&match, strict); assert(iter.get() != nullptr); iter->initRange(DocId(1), reference_attr->getNumDocs()); return iter; } - std::unique_ptr<SearchIterator> - create_non_strict_iterator(ImportedSearchContext& ctx, TermFieldMatchData& match) { + std::unique_ptr<SearchIterator> create_non_strict_iterator( + ImportedSearchContext& ctx, + TermFieldMatchData& match) { return create_iterator(ctx, match, false); } - std::unique_ptr<SearchIterator> - create_strict_iterator(ImportedSearchContext& ctx,TermFieldMatchData& match) { + std::unique_ptr<SearchIterator> create_strict_iterator( + ImportedSearchContext& ctx, + TermFieldMatchData& match) { return create_iterator(ctx, match, true); } @@ -209,31 +210,13 @@ 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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); EXPECT_TRUE(iter->is_strict() == Trinary::True); // No EXPECT_EQUALS printing of Trinary... } -TEST_F("Non-strict blueprint with high hit rate is strict", Fixture(false, FastSearchConfig::ExplicitlyEnabled)) { - auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(queryeval::ExecuteInfo::create(false, 0.02)); - TermFieldMatchData match; - auto iter = f.create_iterator(*ctx, match, false); - - EXPECT_TRUE(iter->is_strict() == Trinary::True); -} - -TEST_F("Non-strict blueprint with low hit rate is non-strict", Fixture(false, FastSearchConfig::ExplicitlyEnabled)) { - auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(queryeval::ExecuteInfo::create(false, 0.01)); - TermFieldMatchData match; - auto iter = f.create_iterator(*ctx, match, false); - - EXPECT_TRUE(iter->is_strict() == Trinary::False); -} - struct SingleValueFixture : Fixture { SingleValueFixture() { reset_with_single_value_reference_mappings<IntegerAttribute, int32_t>( @@ -249,7 +232,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -275,7 +258,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -287,7 +270,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -299,7 +282,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -310,7 +293,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -342,7 +325,7 @@ TEST_F("matches(weight) performs GID mapping and forwards to target attribute", TEST_F("Multiple iterators can be created from the same context", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); TermFieldMatchData match1; auto iter1 = f.create_strict_iterator(*ctx, match1); @@ -397,7 +380,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); 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 @@ -416,7 +399,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(queryeval::ExecuteInfo::TRUE); + ctx->fetchPostings(true); 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 0bb10bcdbe6..9b4c72e1027 100644 --- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp +++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp @@ -10,7 +10,6 @@ #include <vespa/searchlib/attribute/multinumericpostattribute.h> #include <vespa/searchlib/attribute/singlestringpostattribute.h> #include <vespa/searchlib/attribute/multistringpostattribute.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include <vespa/searchlib/parsequery/parse.h> #include <vespa/searchlib/attribute/enumstore.hpp> #include <vespa/searchlib/attribute/attributevector.hpp> @@ -376,7 +375,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch<StringAttribute>(sa); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb))) return false; @@ -389,7 +388,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch<StringAttribute, std::string>(sa, key, false); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -401,7 +400,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, IntegerAttribute { TermFieldMatchData md; SearchContextPtr sc = getSearch<IntegerAttribute, int32_t>(ia, key, false); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -479,7 +478,7 @@ PostingListAttributeTest::checkSearch(bool useBitVector, const AttributeVector & { SearchContextPtr sc = getSearch(vec, term, false, attribute::SearchContextParams().useBitVector(useBitVector)); EXPECT_FALSE( ! sc ); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); size_t approx = sc->approximateHits(); EXPECT_EQUAL(numHits, approx); if (docBegin == 0) { @@ -884,14 +883,15 @@ PostingListAttributeTest::testMinMax(AttributePtr &ptr1, uint32_t trimmed) { TermFieldMatchData md; SearchContextPtr sc = getSearch<VectorType>(as<VectorType>(ptr1)); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&md, true); sb->initFullRange(); const PostingInfo *pi = sb->getPostingInfo(); - ASSERT_TRUE(pi != nullptr); - const MinMaxPostingInfo *mmpi = dynamic_cast<const MinMaxPostingInfo *>(pi); - ASSERT_TRUE(mmpi != nullptr); + ASSERT_TRUE(pi != NULL); + const MinMaxPostingInfo *mmpi = + dynamic_cast<const MinMaxPostingInfo *>(pi); + ASSERT_TRUE(mmpi != NULL); if (ptr1->hasMultiValue()) { if (trimmed == 2u) { @@ -909,17 +909,17 @@ PostingListAttributeTest::testMinMax(AttributePtr &ptr1, uint32_t trimmed) EXPECT_EQUAL(1u, sb->getDocId()); sc = getSearch2<VectorType>(as<VectorType>(ptr1)); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); sb = sc->createIterator(&md, true); sb->initFullRange(); pi = sb->getPostingInfo(); if (trimmed == 2) { - ASSERT_TRUE(pi == nullptr); + ASSERT_TRUE(pi == NULL); } else { - ASSERT_TRUE(pi != nullptr); + ASSERT_TRUE(pi != NULL); mmpi = dynamic_cast<const MinMaxPostingInfo *>(pi); - ASSERT_TRUE(mmpi != nullptr); + ASSERT_TRUE(mmpi != NULL); if (ptr1->hasMultiValue()) { if (trimmed == 0) { 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 4818287b429..7bd755a0f98 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -211,11 +211,11 @@ Result do_search(IAttributeManager &attribute_manager, const Node &node, bool st TermFieldHandle handle = mdl.allocTermField(fieldId); MatchData::UP match_data = mdl.createMatchData(); Blueprint::UP bp = source.createBlueprint(requestContext, FieldSpec(field, fieldId, handle), node); - ASSERT_TRUE(bp); + ASSERT_TRUE(bp.get() != nullptr); Result result(bp->getState().estimate().estHits, bp->getState().estimate().empty); - bp->fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); + bp->fetchPostings(strict); SearchIterator::UP iterator = bp->createSearch(*match_data, strict); - ASSERT_TRUE(iterator); + ASSERT_TRUE(iterator.get() != nullptr); iterator->initRange(1, num_docs); extract_posting_info(result, iterator->getPostingInfo()); extract_wand_params(result, dynamic_cast<ParallelWeakAndSearch*>(iterator.get())); 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 fe5014b6607..f6a9df54be3 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 @@ -103,7 +103,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(queryeval::ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP sb = bp->createSearch(*md, strict); return (dynamic_cast<WeightedSetTermSearch*>(sb.get()) != 0); } @@ -115,7 +115,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(queryeval::ExecuteInfo::create(strict)); + bp->fetchPostings(strict); 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 e9addae07b9..8a63f20822f 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -19,7 +19,6 @@ #include <vespa/searchlib/queryeval/leaf_blueprints.h> #include <vespa/searchlib/queryeval/nearest_neighbor_blueprint.h> #include <vespa/searchlib/tensor/dense_tensor_attribute.h> -#include <vespa/searchlib/fef/matchdata.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -120,7 +119,7 @@ do_search(const Node &node, IAttributeManager &attribute_manager, bool expect_at } else { EXPECT_TRUE(result->get_attribute_search_context() == nullptr); } - result->fetchPostings(queryeval::ExecuteInfo::TRUE); + result->fetchPostings(true); result->setDocIdLimit(DOCID_LIMIT); SearchIterator::UP iterator = result->createSearch(*md, true); assert((bool)iterator); diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp index 7d4a2d63355..b518d683409 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -12,7 +12,6 @@ #include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/searchlib/queryeval/hitcollector.h> #include <vespa/searchlib/queryeval/emptysearch.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/compress.h> #include <vespa/searchlib/test/searchiteratorverifier.h> @@ -205,7 +204,7 @@ private: // test search iterator unpacking void fillForSearchIteratorUnpackingTest(IntegerAttribute * ia, bool extra); void testSearchIteratorUnpacking(const AttributePtr & ptr, SearchContext & sc, bool extra, bool strict) { - sc.fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); + sc.fetchPostings(strict); for (bool withElementId : {false, true}) { testSearchIteratorUnpacking(ptr, sc, extra, strict, withElementId); } @@ -440,7 +439,7 @@ SearchContextTest::performSearch(const V & vec, const T & term, QueryTermSimple: { TermFieldMatchData dummy; SearchContextPtr sc = getSearch(vec, term, termType); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, vec.getNumDocs()); return rs; @@ -496,7 +495,7 @@ SearchContextTest::testFind(const PostingList<V, T> & pl) { { // strict search iterator SearchContextPtr sc = getSearch(pl.getAttribute(), pl.getValue()); - sc->fetchPostings(queryeval::ExecuteInfo::TRUE); + sc->fetchPostings(true); TermFieldMatchData dummy; SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, pl.getAttribute().getNumDocs()); @@ -625,7 +624,7 @@ public: ~Verifier() override; SearchIterator::UP create(bool strict) const override { - _sc->fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); + _sc->fetchPostings(strict); auto search = _sc->createIterator(&_dummy, strict); if (_withElementId) { search = std::make_unique<attribute::ElementIterator>(std::move(search), *_sc, _dummy); @@ -742,7 +741,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with 3 hits - threeHits.fetchPostings(queryeval::ExecuteInfo::TRUE); + threeHits.fetchPostings(true); SearchBasePtr sb = threeHits.createIterator(&dummy, true); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -763,7 +762,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, } { // search for value with no hits - noHits.fetchPostings(queryeval::ExecuteInfo::TRUE); + noHits.fetchPostings(true); SearchBasePtr sb = noHits.createIterator(&dummy, true); sb->initRange(1, noHits.attribute().getCommittedDocIdLimit()); ASSERT_TRUE(typeTester.matches(*sb)); @@ -781,7 +780,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with three hits - threeHits.fetchPostings(queryeval::ExecuteInfo::FALSE); + threeHits.fetchPostings(false); SearchBasePtr sb = threeHits.createIterator(&dummy, false); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -799,7 +798,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, EXPECT_TRUE(sb->getDocId() == 5u || sb->isAtEnd()); } { // search for value with no hits - noHits.fetchPostings(queryeval::ExecuteInfo::FALSE); + noHits.fetchPostings(false); SearchBasePtr sb = noHits.createIterator(&dummy, false); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); diff --git a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp index 243c24f6ab5..d34f824d094 100644 --- a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp +++ b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp @@ -269,13 +269,13 @@ Test::requireThatBlueprintCanCreateSearchIterators() SearchIterator::UP s; { // bit vector due to isFilter b = _index->createBlueprint(_requestContext, FieldSpec("f2", 0, 0, true), makeTerm("w2")); - b->fetchPostings(queryeval::ExecuteInfo::TRUE); + b->fetchPostings(true); s = (dynamic_cast<LeafBlueprint *>(b.get()))->createLeafSearch(mda, true); EXPECT_TRUE(dynamic_cast<BitVectorIterator *>(s.get()) != NULL); } { // bit vector due to no ranking needed b = _index->createBlueprint(_requestContext, FieldSpec("f2", 0, 0, false), makeTerm("w2")); - b->fetchPostings(queryeval::ExecuteInfo::TRUE); + b->fetchPostings(true); s = (dynamic_cast<LeafBlueprint *>(b.get()))->createLeafSearch(mda, true); EXPECT_FALSE(dynamic_cast<BitVectorIterator *>(s.get()) != NULL); TermFieldMatchData md2; @@ -289,7 +289,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(queryeval::ExecuteInfo::TRUE); + b->fetchPostings(true); s = (dynamic_cast<LeafBlueprint *>(b.get()))->createLeafSearch(mda, true); // std::cerr << "SI = " << typeid(*s).name() << std::endl; EXPECT_TRUE((dynamic_cast<BooleanMatchIteratorWrapper *>(s.get()) != NULL) || @@ -297,15 +297,18 @@ Test::requireThatBlueprintCanCreateSearchIterators() } { // posting list iterator b = _index->createBlueprint(_requestContext, FieldSpec("f1", 0, 0), makeTerm("w1")); - b->fetchPostings(queryeval::ExecuteInfo::TRUE); + b->fetchPostings(true); s = (dynamic_cast<LeafBlueprint *>(b.get()))->createLeafSearch(mda, true); ASSERT_TRUE((dynamic_cast<ZcRareWordPosOccIterator<true, false> *>(s.get()) != NULL)); } } -Test::Test() = default; +Test::Test() : + TestDiskIndex() +{ +} -Test::~Test() = default; +Test::~Test() {} int Test::Main() diff --git a/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp b/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp index 71c7c93f756..54124326507 100644 --- a/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp +++ b/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp @@ -2,9 +2,9 @@ #include <vespa/searchcommon/common/schema.h> #include <vespa/searchlib/memoryindex/field_index.h> +#include <vespa/searchlib/memoryindex/posting_iterator.h> #include <vespa/searchlib/test/memoryindex/wrap_inserter.h> #include <vespa/searchlib/test/searchiteratorverifier.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/log/log.h> diff --git a/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp b/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp index 4bb0f91659a..a320c4a0641 100644 --- a/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp +++ b/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp @@ -181,7 +181,7 @@ verifyResult(const FakeResult &expect, EXPECT_EQ(expect.inspect().size(), result->getState().estimate().estHits); EXPECT_EQ(expect.inspect().empty(), result->getState().estimate().empty); - result->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + result->fetchPostings(true); SearchIterator::UP search = result->createSearch(*match_data, true); bool valid_search = search.get() != 0; EXPECT_TRUE(valid_search); @@ -452,7 +452,7 @@ TEST(MemoryIndexTest, require_that_we_can_fake_bit_vector) Blueprint::UP res = searchable.createBlueprint(requestContext, fields, makeTerm(foo)); EXPECT_TRUE(res.get() != NULL); - res->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + res->fetchPostings(true); SearchIterator::UP search = res->createSearch(*match_data, true); EXPECT_TRUE(search.get() != NULL); EXPECT_TRUE(dynamic_cast<BooleanMatchIteratorWrapper *>(search.get()) != NULL); diff --git a/searchlib/src/tests/nearsearch/nearsearch_test.cpp b/searchlib/src/tests/nearsearch/nearsearch_test.cpp index cb17ea35cf8..ce4864a4326 100644 --- a/searchlib/src/tests/nearsearch/nearsearch_test.cpp +++ b/searchlib/src/tests/nearsearch/nearsearch_test.cpp @@ -61,7 +61,7 @@ MyTerm::MyTerm(const std::set<uint32_t> &doc, const std::set<uint32_t> &pos) : _docs(doc), _data(pos) {} -MyTerm::~MyTerm() = default; +MyTerm::~MyTerm() {} class MyQuery { private: @@ -230,7 +230,7 @@ Test::testNearSearch(MyQuery &query, uint32_t matchId) } search::fef::MatchData::UP md(layout.createMatchData()); - bp->fetchPostings(search::queryeval::ExecuteInfo::TRUE); + bp->fetchPostings(true); 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 6625a4a09ce..72a686fddda 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -188,7 +188,7 @@ public: SearchIterator::UP Test::create(const Blueprint &blueprint) { - const_cast<Blueprint &>(blueprint).fetchPostings(ExecuteInfo::TRUE); + const_cast<Blueprint &>(blueprint).fetchPostings(true); 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 4aab1de06b3..9be238edba9 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -1,22 +1,31 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/log/log.h> +LOG_SETUP("blueprint_test"); -#include "mysearch.h" #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/intermediate_blueprints.h> #include <vespa/searchlib/queryeval/leaf_blueprints.h> #include <vespa/searchlib/queryeval/equiv_blueprint.h> +#include <vespa/searchlib/queryeval/searchable.h> + +#include "mysearch.h" + #include <vespa/searchlib/queryeval/multisearch.h> #include <vespa/searchlib/queryeval/andnotsearch.h> +#include <vespa/searchlib/queryeval/andsearch.h> +#include <vespa/searchlib/queryeval/orsearch.h> +#include <vespa/searchlib/queryeval/nearsearch.h> +#include <vespa/searchlib/queryeval/ranksearch.h> #include <vespa/searchlib/queryeval/wand/weak_and_search.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/searchlib/test/diskindex/testdiskindex.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/common/bitvectoriterator.h> +#include <vespa/searchlib/diskindex/zcpostingiterators.h> -#include <vespa/log/log.h> -LOG_SETUP("blueprint_test"); +#include <algorithm> using namespace search::queryeval; using namespace search::fef; @@ -28,17 +37,6 @@ struct WeightOrder { } }; -struct RememberExecuteInfo : public MyLeaf { - ExecuteInfo executeInfo; - - using MyLeaf::MyLeaf; - - void fetchPostings(const ExecuteInfo &execInfo) override { - LeafBlueprint::fetchPostings(execInfo); - executeInfo = execInfo; - } -}; - Blueprint::UP ap(Blueprint *b) { return Blueprint::UP(b); } Blueprint::UP ap(Blueprint &b) { return Blueprint::UP(&b); } @@ -88,25 +86,6 @@ TEST("test AndNot Blueprint") { // createSearch tested by iterator unit test } -TEST("test And propagates updated histestimate") { - AndBlueprint *bp = new AndBlueprint(); - bp->setSourceId(2); - bp->addChild(ap(MyLeafSpec(20).create<RememberExecuteInfo>()->setSourceId(2))); - bp->addChild(ap(MyLeafSpec(200).create<RememberExecuteInfo>()->setSourceId(2))); - bp->addChild(ap(MyLeafSpec(2000).create<RememberExecuteInfo>()->setSourceId(2))); - bp->optimize_self(); - bp->setDocIdLimit(5000); - bp->fetchPostings(ExecuteInfo::create(true)); - EXPECT_EQUAL(3u, bp->childCnt()); - for (uint32_t i = 0; i < bp->childCnt(); i++) { - const RememberExecuteInfo & child = dynamic_cast<const RememberExecuteInfo &>(bp->getChild(i)); - EXPECT_EQUAL((i == 0), child.executeInfo.isStrict()); - } - EXPECT_EQUAL(1.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(0)).executeInfo.hitRate()); - EXPECT_EQUAL(1.0/250, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(1)).executeInfo.hitRate()); - EXPECT_EQUAL(1.0/(250*25), dynamic_cast<const RememberExecuteInfo &>(bp->getChild(2)).executeInfo.hitRate()); -} - TEST("test And Blueprint") { AndBlueprint b; { // combine @@ -1068,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(ExecuteInfo::TRUE); + wa.fetchPostings(true); SearchIterator::UP search = wa.createSearch(*md, true); EXPECT_TRUE(dynamic_cast<WeakAndSearch*>(search.get()) != 0); WeakAndSearch &s = dynamic_cast<WeakAndSearch&>(*search); @@ -1090,7 +1069,7 @@ TEST("test WeakAnd Blueprint") { EXPECT_EQUAL(0u, terms[2].maxScore); // NB: not set } { - wa.fetchPostings(ExecuteInfo::FALSE); + wa.fetchPostings(false); SearchIterator::UP search = wa.createSearch(*md, false); EXPECT_TRUE(dynamic_cast<WeakAndSearch*>(search.get()) != 0); EXPECT_TRUE(search->seek(1)); @@ -1120,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); EXPECT_EQUAL("search::queryeval::OrLikeSearch<false, search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1146,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); EXPECT_EQUAL("search::queryeval::OrLikeSearch<false, search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1165,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict<search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1185,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict<search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1234,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); SearchIterator::UP search = top_up->createSearch(*md, true); EXPECT_EQUAL("search::queryeval::EquivImpl<true>", search->getClassName()); { @@ -1272,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(ExecuteInfo::FALSE); + top_up->fetchPostings(false); SearchIterator::UP search = top_up->createSearch(*md, true); EXPECT_EQUAL("search::queryeval::EquivImpl<true>", 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 dd1d57fc296..2209ab0bfec 100644 --- a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp @@ -1,12 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/log/log.h> +LOG_SETUP("blueprint_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/leaf_blueprints.h> -#include <vespa/searchlib/fef/matchdata.h> - -#include <vespa/log/log.h> -LOG_SETUP("blueprint_test"); +#include <vespa/vespalib/objects/visit.h> using namespace search::queryeval; using namespace search::fef; @@ -29,7 +27,7 @@ Test::testEmptyBlueprint() EXPECT_EQUAL(1u, empty.getState().field(0).getFieldId()); EXPECT_EQUAL(11u, empty.getState().field(0).getHandle()); - empty.fetchPostings(ExecuteInfo::TRUE); + empty.fetchPostings(true); SearchIterator::UP search = empty.createSearch(*md, true); SimpleResult res; @@ -47,7 +45,7 @@ Test::testSimpleBlueprint() SimpleBlueprint simple(a); simple.tag("tag"); EXPECT_EQUAL("tag", simple.tag()); - simple.fetchPostings(ExecuteInfo::TRUE); + simple.fetchPostings(true); SearchIterator::UP search = simple.createSearch(*md, true); SimpleResult res; @@ -69,7 +67,7 @@ Test::testFakeBlueprint() TermFieldHandle handle = 0; FakeBlueprint orig(FieldSpec("<field>", fieldId, handle), fake); - orig.fetchPostings(ExecuteInfo::TRUE); + orig.fetchPostings(true); 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 82ef58147c3..dbd73b6f40e 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -1,9 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/multisearch.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> -#include <vespa/searchlib/fef/matchdata.h> #include <vespa/vespalib/objects/visit.hpp> +#include <cassert> namespace search::queryeval { @@ -94,7 +93,7 @@ public: } } - void visitMembers(vespalib::ObjectVisitor &visitor) const override { + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override { visit(visitor, "_tag", _tag); visit(visitor, "_isLeaf", _isLeaf); visit(visitor, "_isStrict", _isStrict); @@ -102,7 +101,7 @@ public: visit(visitor, "_handles", _handles); } - ~MySearch() override {} + virtual ~MySearch() {} }; //----------------------------------------------------------------------------- @@ -112,7 +111,7 @@ class MyLeaf : public SimpleLeafBlueprint typedef search::fef::TermFieldMatchDataArray TFMDA; public: - SearchIterator::UP + virtual SearchIterator::UP createLeafSearch(const TFMDA &tfmda, bool strict) const override { return SearchIterator::UP(new MySearch("leaf", tfmda, strict)); @@ -156,11 +155,7 @@ public: return *this; } MyLeaf *create() const { - return create<MyLeaf>(); - } - template<typename Leaf> - Leaf *create() const { - Leaf *leaf = new Leaf(_fields); + MyLeaf *leaf = new MyLeaf(_fields); leaf->estimate(_estimate.estHits, _estimate.empty); if (_cost_tier > 0) { leaf->cost_tier(_cost_tier); 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 7414e8b10f2..f1b6cd05772 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(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP sb = bp->createSearch(*md, strict); EXPECT_TRUE(dynamic_cast<DotProductSearch*>(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 ecd1c8cd218..5dac26fec22 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(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); 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 cbad6de25bb..6fc75c8e696 100644 --- a/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp +++ b/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp @@ -62,7 +62,7 @@ TEST_F(FakeSearchableTest, require_that_term_search_works) { bool strict = (i == 0); SCOPED_TRACE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -116,7 +116,7 @@ TEST_F(FakeSearchableTest, require_that_phrase_search_works) { bool strict = (i == 0); SCOPED_TRACE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -167,7 +167,7 @@ TEST_F(FakeSearchableTest, require_that_weigheted_set_search_works) { bool strict = (i == 0); SCOPED_TRACE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -238,7 +238,7 @@ TEST_F(FakeSearchableTest, require_that_multi_field_search_works) { bool strict = (i == 0); SCOPED_TRACE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -322,7 +322,7 @@ TEST_F(FakeSearchableTest, require_that_phrase_with_empty_child_works) { bool strict = (i == 0); SCOPED_TRACE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); @@ -342,7 +342,7 @@ TEST_F(FakeSearchableTest, require_that_match_data_is_compressed_for_attributes) fields.add(FieldSpec("attrfoo", 1, 1)); Blueprint::UP bp = source.createBlueprint(req_ctx, fields, termNode); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::FALSE); + bp->fetchPostings(false); SearchIterator::UP search = bp->createSearch(*md, false); search->initFullRange(); EXPECT_TRUE(search->seek(5)); @@ -369,7 +369,7 @@ TEST_F(FakeSearchableTest, require_that_relevant_data_can_be_obtained_from_fake_ fields.add(FieldSpec("attrfoo", 1, 1)); Blueprint::UP bp = source.createBlueprint(req_ctx, fields, termNode); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(ExecuteInfo::FALSE); + bp->fetchPostings(false); SearchIterator::UP search = bp->createSearch(*md, false); EXPECT_TRUE(bp->get_attribute_search_context() != nullptr); const auto *attr_ctx = bp->get_attribute_search_context(); 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 7926a518317..607e6100f90 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(ExecuteInfo::TRUE); + bp->fetchPostings(true); bp->setDocIdLimit(docIdLimit); SearchIterator::UP sb = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast<ParallelWeakAndSearch*>(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(ExecuteInfo::TRUE); + bp->fetchPostings(true); bp->setDocIdLimit(docIdLimit); SearchIterator::UP sb = bp->createSearch(*md, true); EXPECT_TRUE(dynamic_cast<ParallelWeakAndSearch*>(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 28b0d103040..c76873a50cd 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp @@ -26,7 +26,6 @@ using search::query::Weight; using search::queryeval::FieldSpecBase; using search::queryeval::PredicateBlueprint; using search::queryeval::SearchIterator; -using search::queryeval::ExecuteInfo; namespace { @@ -138,7 +137,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(ExecuteInfo::TRUE); + blueprint.fetchPostings(true); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -162,7 +161,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(ExecuteInfo::TRUE); + blueprint.fetchPostings(true); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -185,7 +184,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(ExecuteInfo::TRUE); + blueprint.fetchPostings(true); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -201,7 +200,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(ExecuteInfo::TRUE); + blueprint.fetchPostings(true); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -225,7 +224,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(ExecuteInfo::TRUE); + blueprint.fetchPostings(true); 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 26e7095dd60..56c6f7e1282 100644 --- a/searchlib/src/tests/queryeval/queryeval.cpp +++ b/searchlib/src/tests/queryeval/queryeval.cpp @@ -225,7 +225,7 @@ TEST("testAnd") { auto and_b = std::make_unique<AndBlueprint>(); and_b->addChild(std::make_unique<SimpleBlueprint>(a)); and_b->addChild(std::make_unique<SimpleBlueprint>(b)); - and_b->fetchPostings(ExecuteInfo::TRUE); + and_b->fetchPostings(true); SearchIterator::UP and_ab = and_b->createSearch(*md, true); EXPECT_TRUE(dynamic_cast<const AndSearch *>(and_ab.get()) != nullptr); @@ -252,7 +252,7 @@ TEST("testOr") { auto or_b = std::make_unique<OrBlueprint>(); or_b->addChild(std::make_unique<SimpleBlueprint>(a)); or_b->addChild(std::make_unique<SimpleBlueprint>(b)); - or_b->fetchPostings(ExecuteInfo::TRUE); + or_b->fetchPostings(true); SearchIterator::UP or_ab = or_b->createSearch(*md, true); SimpleResult res; @@ -366,7 +366,7 @@ TEST("testAndNot") { auto andnot_b = std::make_unique<AndNotBlueprint>(); andnot_b->addChild(std::make_unique<SimpleBlueprint>(a)); andnot_b->addChild(std::make_unique<SimpleBlueprint>(b)); - andnot_b->fetchPostings(ExecuteInfo::TRUE); + andnot_b->fetchPostings(true); SearchIterator::UP andnot_ab = andnot_b->createSearch(*md, true); SimpleResult res; @@ -386,7 +386,7 @@ TEST("testAndNot") { auto andnot_b = std::make_unique<AndNotBlueprint>(); andnot_b->addChild(std::make_unique<SimpleBlueprint>(a)); andnot_b->addChild(std::make_unique<DummySingleValueBitNumericAttributeBlueprint>(b)); - andnot_b->fetchPostings(ExecuteInfo::TRUE); + andnot_b->fetchPostings(true); SearchIterator::UP andnot_ab = andnot_b->createSearch(*md, true); SimpleResult res; @@ -412,7 +412,7 @@ TEST("testAndNot") { auto and_b = std::make_unique<AndBlueprint>(); and_b->addChild(std::make_unique<SimpleBlueprint>(c)); and_b->addChild(std::move(andnot_b)); - and_b->fetchPostings(ExecuteInfo::TRUE); + and_b->fetchPostings(true); SearchIterator::UP and_cab = and_b->createSearch(*md, true); SimpleResult res; @@ -437,7 +437,7 @@ TEST("testRank") { auto rank_b = std::make_unique<RankBlueprint>(); rank_b->addChild(std::make_unique<SimpleBlueprint>(a)); rank_b->addChild(std::make_unique<SimpleBlueprint>(b)); - rank_b->fetchPostings(ExecuteInfo::TRUE); + rank_b->fetchPostings(true); SearchIterator::UP rank_ab = rank_b->createSearch(*md, true); SimpleResult res; diff --git a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp index 378e16480b8..a4ca1ade999 100644 --- a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp +++ b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp @@ -37,7 +37,7 @@ std::unique_ptr<SameElementBlueprint> make_blueprint(const std::vector<FakeResul Blueprint::UP finalize(Blueprint::UP bp, bool strict) { Blueprint::UP result = Blueprint::optimize(std::move(bp)); - result->fetchPostings(ExecuteInfo::create(strict)); + result->fetchPostings(strict); result->freeze(); return result; } 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 abaae7e4333..0743ac8408d 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -138,13 +138,12 @@ public: void fetchPostings(bool useBlueprint) { - ExecuteInfo execInfo = ExecuteInfo::create(_strict); if (useBlueprint) { - _phrase.fetchPostings(execInfo); + _phrase.fetchPostings(_strict); return; } for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->fetchPostings(execInfo); + _children[i]->fetchPostings(_strict); } } diff --git a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp index 64ff8898bb0..2cd687ab23a 100644 --- a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp +++ b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp @@ -9,7 +9,6 @@ #include <vespa/searchlib/test/searchiteratorverifier.h> #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/attribute/fixedsourceselector.h> -#include <vespa/searchlib/fef/matchdata.h> using namespace search::queryeval; using namespace search::fef; @@ -74,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(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP search = bp->createSearch(*md, strict); search->initFullRange(); SearchIterator &blend = *search; diff --git a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp index 8d70daa4ca8..9f4c0058b93 100644 --- a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp +++ b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp @@ -11,7 +11,6 @@ #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/searchlib/test/searchiteratorverifier.h> #include <vespa/searchlib/common/bitvectoriterator.h> -#include <vespa/searchlib/fef/matchdata.h> #include <vespa/vespalib/objects/visit.hpp> using namespace vespalib; @@ -82,15 +81,15 @@ struct MyBlueprint : SimpleLeafBlueprint { setEstimate(HitEstimate(hits.size(), hits.empty())); set_allow_termwise_eval(allow_termwise_eval); } - ~MyBlueprint() override; + ~MyBlueprint(); SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &, bool strict) const override { - return std::make_unique<MyTerm>(hits, strict); + return SearchIterator::UP(new MyTerm(hits, strict)); } }; -MyBlueprint::~MyBlueprint() = default; +MyBlueprint::~MyBlueprint() {} struct MyOr : OrBlueprint { bool use_my_value; 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 85d2f3f4a37..78195f19427 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(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP sb = bp->createSearch(*md, strict); return (dynamic_cast<WeightedSetTermSearch*>(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(ExecuteInfo::create(strict)); + bp->fetchPostings(strict); SearchIterator::UP sb = bp->createSearch(*md, strict); sb->initFullRange(); FakeResult result; diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 8595b0eff7f..29298a05d6e 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -28,7 +28,6 @@ #include <vespa/searchlib/queryeval/wand/parallel_weak_and_search.h> #include <vespa/searchlib/queryeval/weighted_set_term_blueprint.h> #include <vespa/searchlib/queryeval/weighted_set_term_search.h> -#include <vespa/searchlib/queryeval/field_spec.hpp> #include <vespa/searchlib/tensor/dense_tensor_attribute.h> #include <vespa/vespalib/util/regexp.h> #include <vespa/vespalib/util/stringfmt.h> @@ -140,8 +139,8 @@ public: } void - fetchPostings(const queryeval::ExecuteInfo &execInfo) override { - _search_context->fetchPostings(execInfo); + fetchPostings(bool strict) override { + _search_context->fetchPostings(strict); } void visitMembers(vespalib::ObjectVisitor &visitor) const override; @@ -220,9 +219,9 @@ public: } } - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override { + void fetchPostings(bool strict) override { for (size_t i(0); i < _rangeSearches.size(); i++) { - _rangeSearches[i]->fetchPostings(execInfo); + _rangeSearches[i]->fetchPostings(strict); } } }; 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 9f9d5535014..9195ce30c6e 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp @@ -178,11 +178,11 @@ AttributeWeightedSetBlueprint::createLeafSearch(const fef::TermFieldMatchDataArr } void -AttributeWeightedSetBlueprint::fetchPostings(const queryeval::ExecuteInfo &execInfo) +AttributeWeightedSetBlueprint::fetchPostings(bool strict) { - if (execInfo.isStrict()) { + if (strict) { for (auto * context : _contexts) { - context->fetchPostings(execInfo); + context->fetchPostings(true); } } } 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 6af3405c91d..d66a544e77a 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h @@ -29,7 +29,7 @@ public: ~AttributeWeightedSetBlueprint(); void addToken(std::unique_ptr<ISearchContext> context, int32_t weight); queryeval::SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; }; diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index b043bb4aaf8..4c060c5fab8 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -526,9 +526,9 @@ createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) void -AttributeVector::SearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) { +AttributeVector::SearchContext::fetchPostings(bool strict) { if (_plsc != nullptr) - _plsc->fetchPostings(execInfo); + _plsc->fetchPostings(strict); } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index b5f6beaa718..48ef8257329 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -522,7 +522,7 @@ public: unsigned int approximateHits() const override; queryeval::SearchIterator::UP createIterator(fef::TermFieldMatchData *matchData, bool strict) override; - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; bool valid() const override { return false; } Int64Range getAsIntegerTerm() const override { return Int64Range(); } const QueryTermUCS4 * queryTerm() const override { diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp index 3b9f3d6f47c..28a270555d3 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp @@ -39,8 +39,9 @@ EnumHintSearchContext::lookupRange(const datastore::EntryComparator &low, } void -EnumHintSearchContext::fetchPostings(const queryeval::ExecuteInfo &) +EnumHintSearchContext::fetchPostings(bool strict) { + (void) strict; } SearchIterator::UP diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h index b83ea2e6c46..5a20318ae7b 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h @@ -28,7 +28,7 @@ protected: EnumHintSearchContext(const IEnumStoreDictionary &dictionary, uint32_t docIdLimit, uint64_t numValues); - ~EnumHintSearchContext() override; + ~EnumHintSearchContext(); void lookupTerm(const datastore::EntryComparator &comp); void lookupRange(const datastore::EntryComparator &low, const datastore::EntryComparator &high); @@ -36,7 +36,7 @@ protected: queryeval::SearchIterator::UP createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) override; - void fetchPostings(const queryeval::ExecuteInfo & execInfo) override; + void fetchPostings(bool strict) override; unsigned int approximateHits() const override; }; diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h index 395f20ea403..33afaaf7f1e 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h @@ -4,6 +4,7 @@ #include "readable_attribute_vector.h" #include <vespa/vespalib/stllike/string.h> +#include <memory> namespace search { struct IDocumentMetaStoreContext; } @@ -38,7 +39,7 @@ public: std::shared_ptr<ReadableAttributeVector> target_attribute, std::shared_ptr<const IDocumentMetaStoreContext> target_document_meta_store, std::shared_ptr<BitVectorSearchCache> search_cache); - ~ImportedAttributeVector() override; + virtual ~ImportedAttributeVector(); const std::shared_ptr<ReferenceAttribute>& getReferenceAttribute() const noexcept { return _reference_attribute; diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_factory.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_factory.h index 5401a54f84f..994d2b22ab9 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_factory.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_factory.h @@ -5,9 +5,11 @@ #include <vespa/vespalib/stllike/string.h> #include <memory> -namespace search { struct IDocumentMetaStoreContext; } +namespace search { -namespace search::attribute { +struct IDocumentMetaStoreContext; + +namespace attribute { class BitVectorSearchCache; class ImportedAttributeVector; @@ -37,4 +39,5 @@ public: std::shared_ptr<BitVectorSearchCache> search_cache); }; -} +} // attribute +} // search diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp index f146378782c..49ae5209aa0 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp @@ -7,7 +7,6 @@ #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/query/query_term_ucs4.h> #include <vespa/searchlib/queryeval/emptysearch.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include "attributeiterators.hpp" #include <vespa/log/log.h> @@ -231,14 +230,12 @@ ImportedSearchContext::considerAddSearchCacheEntry() } } -void ImportedSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) { +void ImportedSearchContext::fetchPostings(bool strict) { assert(!_fetchPostingsDone); _fetchPostingsDone = true; if (!_searchCacheLookup) { - _target_search_context->fetchPostings(execInfo); - if (execInfo.isStrict() - || (_target_attribute.getIsFastSearch() && execInfo.hitRate() > 0.01)) - { + _target_search_context->fetchPostings(strict); + 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 2663978c99a..2ceb61bc2b2 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<queryeval::SearchIterator> createIterator(fef::TermFieldMatchData* matchData, bool strict) override; unsigned int approximateHits() const override; - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; bool valid() const override; Int64Range getAsIntegerTerm() const override; const QueryTermUCS4 * queryTerm() const override; diff --git a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h index 674b2fcc8c7..097cc35d8cb 100644 --- a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h @@ -4,10 +4,7 @@ #include <memory> -namespace search::queryeval { - class SearchIterator; - class ExecuteInfo; -} +namespace search::queryeval { class SearchIterator; } namespace search::fef { class TermFieldMatchData; } namespace search::attribute { @@ -28,7 +25,7 @@ protected: virtual ~IPostingListSearchContext() { } public: - virtual void fetchPostings(const queryeval::ExecuteInfo & execInfo) = 0; + virtual void fetchPostings(bool strict) = 0; virtual std::unique_ptr<queryeval::SearchIterator> createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) = 0; virtual unsigned int approximateHits() const = 0; }; diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h index 43d8b7ce9d2..68b9ae5da7b 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h @@ -116,14 +116,14 @@ protected: PostingListSearchContextT(const Dictionary &dictionary, uint32_t docIdLimit, uint64_t numValues, bool hasWeight, const PostingList &postingList, const IEnumStore &esb, uint32_t minBvCocFreq, bool useBitVector, const ISearchContext &baseSearchCtx); - ~PostingListSearchContextT() override; + ~PostingListSearchContextT(); void lookupSingle(); size_t countHits() const; void fillArray(); void fillBitVector(); - void fetchPostings(const queryeval::ExecuteInfo & strict) override; + void fetchPostings(bool strict) 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); @@ -229,7 +229,7 @@ private: ? limit : estimate; } - void fetchPostings(const queryeval::ExecuteInfo & execInfo) override { + void fetchPostings(bool strict) override { if (params().diversityAttribute() != nullptr) { bool forward = (this->getRangeLimit() > 0); size_t wanted_hits = std::abs(this->getRangeLimit()); @@ -237,7 +237,7 @@ private: *(params().diversityAttribute()), this->getMaxPerGroup(), params().diversityCutoffGroups(), params().diversityCutoffStrict()); } else { - PostingListSearchContextT<DataT>::fetchPostings(execInfo); + PostingListSearchContextT<DataT>::fetchPostings(strict); } } @@ -267,7 +267,7 @@ PostingSearchContext(QueryTermSimpleUP qTerm, bool useBitVector, const AttrT &to } template <typename BaseSC, typename BaseSC2, typename AttrT> -PostingSearchContext<BaseSC, BaseSC2, AttrT>::~PostingSearchContext() = default; +PostingSearchContext<BaseSC, BaseSC2, AttrT>::~PostingSearchContext() { } template <typename BaseSC, typename AttrT, typename DataT> diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp index e60cd4f5887..ed6a4a06478 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp @@ -6,11 +6,10 @@ #include "attributeiterators.h" #include "diversity.h" #include "postingstore.hpp" -#include "posting_list_traverser.h" #include <vespa/searchlib/queryeval/emptysearch.h> -#include <vespa/searchlib/queryeval/executeinfo.h> #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/common/growablebitvector.h> +#include "posting_list_traverser.h" using search::queryeval::EmptySearch; @@ -114,7 +113,7 @@ PostingListSearchContextT<DataT>::fillBitVector() template <typename DataT> void -PostingListSearchContextT<DataT>::fetchPostings(const queryeval::ExecuteInfo & execInfo) +PostingListSearchContextT<DataT>::fetchPostings(bool strict) { if (_fetchPostingsDone) return; @@ -122,7 +121,7 @@ PostingListSearchContextT<DataT>::fetchPostings(const queryeval::ExecuteInfo & e if (_uniqueValues < 2u) return; - if (execInfo.isStrict() && !fallbackToFiltering()) { + if (strict && !fallbackToFiltering()) { size_t sum(countHits()); if (sum < _docIdLimit / 64) { _merger.reserveArray(_uniqueValues, sum); diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp index e1277653b83..bb930e303b6 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp @@ -127,7 +127,7 @@ public: std::unique_ptr<queryeval::SearchIterator> createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) override; - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; std::unique_ptr<queryeval::SearchIterator> createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) override; unsigned int approximateHits() const override; }; @@ -157,8 +157,8 @@ BitVectorSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData } void -BitVectorSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) { - (void) execInfo; +BitVectorSearchContext::fetchPostings(bool strict) { + (void) strict; } std::unique_ptr<queryeval::SearchIterator> diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp index 4febe165665..194aea5344b 100644 --- a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp @@ -66,9 +66,9 @@ areAnyParentsEquiv(const Blueprint * node) } void -DiskTermBlueprint::fetchPostings(const queryeval::ExecuteInfo &execInfo) +DiskTermBlueprint::fetchPostings(bool strict) { - (void) execInfo; + (void) strict; _hasEquivParent = areAnyParentsEquiv(getParent()); _bitVector = _diskIndex.readBitVector(*_lookupRes); if (!_useBitVector || !_bitVector) { diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h index 39ac27bc448..f3e9a29dca0 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<queryeval::SearchIterator> createLeafSearch(const fef::TermFieldMatchDataArray & tfmda, bool strict) const override; - void fetchPostings(const queryeval::ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; }; } diff --git a/searchlib/src/vespa/searchlib/memoryindex/posting_iterator.cpp b/searchlib/src/vespa/searchlib/memoryindex/posting_iterator.cpp index c4d2c335689..735fec2bb5f 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/posting_iterator.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/posting_iterator.cpp @@ -2,7 +2,6 @@ #include "posting_iterator.h" #include <vespa/searchlib/queryeval/iterators.h> -#include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/vespalib/btree/btreeiterator.hpp> #include <vespa/vespalib/btree/btreenode.hpp> #include <vespa/vespalib/btree/btreenodeallocator.hpp> diff --git a/searchlib/src/vespa/searchlib/queryeval/CMakeLists.txt b/searchlib/src/vespa/searchlib/queryeval/CMakeLists.txt index de2919443ff..d8774d86edf 100644 --- a/searchlib/src/vespa/searchlib/queryeval/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/queryeval/CMakeLists.txt @@ -12,7 +12,6 @@ vespa_add_library(searchlib_queryeval OBJECT emptysearch.cpp equiv_blueprint.cpp equivsearch.cpp - executeinfo.cpp fake_requestcontext.cpp fake_result.cpp fake_search.cpp diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index 509224eebc0..1019ef9dd68 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -3,8 +3,7 @@ #include "blueprint.h" #include "leaf_blueprints.h" #include "intermediate_blueprints.h" -#include "field_spec.hpp" -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> +#include "equiv_blueprint.h" #include <vespa/vespalib/objects/visit.hpp> #include <vespa/vespalib/objects/objectdumper.h> #include <vespa/vespalib/objects/object2slime.h> @@ -171,18 +170,10 @@ namespace blueprint { void StateCache::updateState() const { - assert(!frozen()); _state = calculateState(); _stale = false; } -void -StateCache::notifyChange() { - assert(!frozen()); - Blueprint::notifyChange(); - _stale = true; -} - } // namespace blueprint //----------------------------------------------------------------------------- @@ -317,13 +308,6 @@ IntermediateBlueprint::calculateState() const return state; } -double -IntermediateBlueprint::computeNextHitRate(const Blueprint & child, double hitRate) const -{ - (void) child; - return hitRate; -} - bool IntermediateBlueprint::should_do_termwise_eval(const UnpackInfo &unpack, double match_limit) const { @@ -419,13 +403,11 @@ IntermediateBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const } void -IntermediateBlueprint::fetchPostings(const ExecuteInfo &execInfo) +IntermediateBlueprint::fetchPostings(bool strict) { - double nextHitRate = execInfo.hitRate(); for (size_t i = 0; i < _children.size(); ++i) { - Blueprint & child = *_children[i]; - child.fetchPostings(ExecuteInfo::create(execInfo.isStrict() && inheritStrict(i), nextHitRate)); - nextHitRate = computeNextHitRate(child, nextHitRate); + bool strictChild = (strict && inheritStrict(i)); + _children[i]->fetchPostings(strictChild); } } @@ -512,9 +494,9 @@ LeafBlueprint::LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwis LeafBlueprint::~LeafBlueprint() = default; void -LeafBlueprint::fetchPostings(const ExecuteInfo &execInfo) +LeafBlueprint::fetchPostings(bool strict) { - (void) execInfo; + (void) strict; } void diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index 18fa360421f..383e63a2edd 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -4,7 +4,10 @@ #include "field_spec.h" #include "unpackinfo.h" -#include "executeinfo.h" +#include <vespa/searchlib/fef/handle.h> +#include <vespa/searchlib/fef/matchdata.h> +#include <vespa/searchlib/fef/termfieldmatchdata.h> +#include <vespa/searchlib/fef/termfieldmatchdataarray.h> namespace vespalib { class ObjectVisitor; } namespace vespalib::slime { @@ -12,15 +15,10 @@ namespace vespalib::slime { struct Inserter; } namespace search::attribute { class ISearchContext; } -namespace search::fef { - class TermFieldMatchDataArray; - class MatchData; -} namespace search::queryeval { class SearchIterator; -class ExecuteInfo; /** * A Blueprint is an intermediate representation of a search. More @@ -188,7 +186,7 @@ public: double hit_ratio() const { return getState().hit_ratio(_docid_limit); } - virtual void fetchPostings(const ExecuteInfo &execInfo) = 0; + virtual void fetchPostings(bool strict) = 0; virtual void freeze() = 0; bool frozen() const { return _frozen; } @@ -217,13 +215,18 @@ private: void updateState() const; protected: - void notifyChange() override final; + void notifyChange() override final { + assert(!frozen()); + Blueprint::notifyChange(); + _stale = true; + } virtual State calculateState() const = 0; public: StateCache() : _stale(true), _state(FieldSpecBaseList()) {} const State &getState() const override final { if (_stale) { + assert(!frozen()); updateState(); } return _state; @@ -246,7 +249,6 @@ private: bool infer_allow_termwise_eval() const; size_t count_termwise_nodes(const UnpackInfo &unpack) const; - virtual double computeNextHitRate(const Blueprint & child, double hitRate) const; protected: // returns an empty collection if children have empty or @@ -286,7 +288,7 @@ public: bool strict, fef::MatchData &md) const = 0; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; void freeze() override final; UnpackInfo calculateUnpackInfo(const fef::MatchData & md) const; @@ -311,7 +313,7 @@ public: ~LeafBlueprint() override; const State &getState() const override final { return _state; } void setDocIdLimit(uint32_t limit) override final { Blueprint::setDocIdLimit(limit); } - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; void freeze() override final; SearchIteratorUP createSearch(fef::MatchData &md, bool strict) const override; diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp index 741aec98f4f..f76cd0d6acc 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp @@ -2,7 +2,6 @@ #include "dot_product_blueprint.h" #include "dot_product_search.h" -#include "field_spec.hpp" #include <vespa/vespalib/objects/visit.hpp> namespace search::queryeval { @@ -65,11 +64,11 @@ DotProductBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray } void -DotProductBlueprint::fetchPostings(const ExecuteInfo &execInfo) +DotProductBlueprint::fetchPostings(bool strict) { - ExecuteInfo childInfo = ExecuteInfo::create(true, execInfo.hitRate()); + (void) strict; for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(childInfo); + _terms[i]->fetchPostings(true); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h index 86c8e90300a..e19a6cdb7f9 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h @@ -34,7 +34,7 @@ public: bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp index 08a05b25772..bdd64f4c938 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp @@ -2,10 +2,10 @@ #include "equiv_blueprint.h" #include "equivsearch.h" -#include "field_spec.hpp" #include <vespa/vespalib/objects/visit.hpp> -namespace search::queryeval { +namespace search { +namespace queryeval { EquivBlueprint::EquivBlueprint(const FieldSpecBaseList &fields, fef::MatchDataLayout subtree_mdl) @@ -18,14 +18,17 @@ EquivBlueprint::EquivBlueprint(const FieldSpecBaseList &fields, { } -EquivBlueprint::~EquivBlueprint() = default; +EquivBlueprint::~EquivBlueprint() +{ +} SearchIterator::UP -EquivBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &outputs, bool strict) const +EquivBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray &outputs, + bool strict) const { fef::MatchData::UP md = _layout.createMatchData(); MultiSearch::Children children(_terms.size()); - fef::TermMatchDataMerger::Inputs childMatch; + search::fef::TermMatchDataMerger::Inputs childMatch; for (size_t i = 0; i < _terms.size(); ++i) { const State &childState = _terms[i]->getState(); for (size_t j = 0; j < childState.numFields(); ++j) { @@ -44,10 +47,10 @@ EquivBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const } void -EquivBlueprint::fetchPostings(const ExecuteInfo &execInfo) +EquivBlueprint::fetchPostings(bool strict) { for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(execInfo); + _terms[i]->fetchPostings(strict); } } @@ -66,4 +69,6 @@ EquivBlueprint::addTerm(Blueprint::UP term, double exactness) return *this; } -} + +} // 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 59ed5ad5d3d..09a41ab13df 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h @@ -27,7 +27,7 @@ public: SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; bool isEquiv() const override { return true; } }; diff --git a/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp b/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp index 593701fd14f..0d97ade09d1 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp @@ -2,7 +2,8 @@ #include "equivsearch.h" -namespace search::queryeval { +namespace search { +namespace queryeval { template <bool strict> class EquivImpl : public OrLikeSearch<strict, NoUnpack> @@ -23,15 +24,15 @@ public: **/ EquivImpl(const MultiSearch::Children &children, fef::MatchData::UP inputMatchData, - const fef::TermMatchDataMerger::Inputs &inputs, + const search::fef::TermMatchDataMerger::Inputs &inputs, const fef::TermFieldMatchDataArray &outputs); }; template<bool strict> EquivImpl<strict>::EquivImpl(const MultiSearch::Children &children, fef::MatchData::UP inputMatchData, - const fef::TermMatchDataMerger::Inputs &inputs, - const fef::TermFieldMatchDataArray &outputs) + const search::fef::TermMatchDataMerger::Inputs &inputs, + const search::fef::TermFieldMatchDataArray &outputs) : OrLikeSearch<strict, NoUnpack>(children, NoUnpack()), _inputMatchData(std::move(inputMatchData)), @@ -53,8 +54,8 @@ EquivImpl<strict>::doUnpack(uint32_t docid) SearchIterator * EquivSearch::create(const Children &children, fef::MatchData::UP inputMatchData, - const fef::TermMatchDataMerger::Inputs &inputs, - const fef::TermFieldMatchDataArray &outputs, + const search::fef::TermMatchDataMerger::Inputs &inputs, + const search::fef::TermFieldMatchDataArray &outputs, bool strict) { if (strict) { @@ -64,4 +65,5 @@ EquivSearch::create(const Children &children, } } -} +} // namespace queryeval +} // namespace search diff --git a/searchlib/src/vespa/searchlib/queryeval/equivsearch.h b/searchlib/src/vespa/searchlib/queryeval/equivsearch.h index 252e17e610a..580889c429c 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equivsearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/equivsearch.h @@ -8,7 +8,8 @@ #include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/searchlib/fef/termmatchdatamerger.h> -namespace search::queryeval { +namespace search { +namespace queryeval { /** * A simple implementation of the Equiv search operation. @@ -21,9 +22,11 @@ public: // Caller takes ownership of the returned SearchIterator. static SearchIterator *create(const Children &children, fef::MatchData::UP inputMD, - const fef::TermMatchDataMerger::Inputs &inputs, - const fef::TermFieldMatchDataArray &outputs, + const search::fef::TermMatchDataMerger::Inputs &inputs, + const search::fef::TermFieldMatchDataArray &outputs, bool strict); }; -} +} // namespace queryeval +} // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp deleted file mode 100644 index 5282a5c570a..00000000000 --- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "executeinfo.h" - -namespace search::queryeval { - -const ExecuteInfo ExecuteInfo::TRUE(true, 1.0); -const ExecuteInfo ExecuteInfo::FALSE(false, 1.0); - -ExecuteInfo -ExecuteInfo::create(bool strict) { - return create(strict, 1.0); -} - -ExecuteInfo -ExecuteInfo::create(bool strict, double hitRate) { - return ExecuteInfo(strict, hitRate); -} - -} diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h deleted file mode 100644 index a00e86bd540..00000000000 --- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 Oath inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -namespace search::queryeval { - -/** - * Holds information about how query will be executed and how large part of corpus will pass through. - * @author baldersheim - */ -class ExecuteInfo { -public: - ExecuteInfo() : ExecuteInfo(false, 1.0) { } - bool isStrict() const { return _strict; } - double hitRate() const { return _hitRate; } - static const ExecuteInfo TRUE; - static const ExecuteInfo FALSE; - static ExecuteInfo create(bool strict); - static ExecuteInfo create(bool strict, double HitRate); -private: - ExecuteInfo(bool strict, double hitRate_in) - : _hitRate(hitRate_in), - _strict(strict) - { } - double _hitRate; - bool _strict; -}; - -} diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_result.h b/searchlib/src/vespa/searchlib/queryeval/fake_result.h index bbae5e027cf..ddf1fa61b63 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_result.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_result.h @@ -6,7 +6,6 @@ #include <vespa/searchlib/common/feature.h> #include <vespa/searchlib/common/fslimits.h> #include <vector> -#include <memory> namespace search::queryeval { @@ -43,7 +42,7 @@ public: private: std::vector<Document> _documents; - std::shared_ptr<MinMaxPostingInfo> _minMaxPostingInfo; + MinMaxPostingInfo::SP _minMaxPostingInfo; public: FakeResult(); diff --git a/searchlib/src/vespa/searchlib/queryeval/field_spec.h b/searchlib/src/vespa/searchlib/queryeval/field_spec.h index fd3de63cae0..b274e2c6751 100644 --- a/searchlib/src/vespa/searchlib/queryeval/field_spec.h +++ b/searchlib/src/vespa/searchlib/queryeval/field_spec.h @@ -3,13 +3,10 @@ #pragma once #include <vespa/searchlib/fef/handle.h> +#include <vespa/searchlib/fef/matchdata.h> #include <vespa/vespalib/stllike/string.h> #include <vector> -namespace search::fef { - class MatchData; - class TermFieldMatchData; -} namespace search::queryeval { /** @@ -21,8 +18,12 @@ public: FieldSpecBase(uint32_t fieldId, fef::TermFieldHandle handle, bool isFilter_ = false); // resolve where to put match information for this term/field combination - fef::TermFieldMatchData *resolve(fef::MatchData &md) const; - const fef::TermFieldMatchData *resolve(const fef::MatchData &md) const; + search::fef::TermFieldMatchData *resolve(search::fef::MatchData &md) const { + return md.resolveTermField(getHandle()); + } + const search::fef::TermFieldMatchData *resolve(const search::fef::MatchData &md) const { + return md.resolveTermField(getHandle()); + } uint32_t getFieldId() const { return _fieldId & 0xffffff; } fef::TermFieldHandle getHandle() const { return _handle; } /// a filter produces less detailed match data @@ -44,6 +45,10 @@ public: _name(name) {} + // resolve where to put match information for this term/field combination + search::fef::TermFieldMatchData *resolve(search::fef::MatchData &md) const { + return md.resolveTermField(getHandle()); + } const vespalib::string & getName() const { return _name; } private: vespalib::string _name; // field name diff --git a/searchlib/src/vespa/searchlib/queryeval/field_spec.hpp b/searchlib/src/vespa/searchlib/queryeval/field_spec.hpp deleted file mode 100644 index e772f95ec19..00000000000 --- a/searchlib/src/vespa/searchlib/queryeval/field_spec.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "field_spec.h" -#include <vespa/searchlib/fef/matchdata.h> - -namespace search::queryeval { - -inline fef::TermFieldMatchData * -FieldSpecBase::resolve(fef::MatchData &md) const { - return md.resolveTermField(getHandle()); -} -inline const fef::TermFieldMatchData * -FieldSpecBase::resolve(const fef::MatchData &md) const { - return md.resolveTermField(getHandle()); -} - -} diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp index 430bc3956e7..b40613010dc 100644 --- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp @@ -7,9 +7,9 @@ #include "nearsearch.h" #include "ranksearch.h" #include "sourceblendersearch.h" +#include "equivsearch.h" #include "termwise_blueprint_helper.h" #include "isourceselector.h" -#include "field_spec.hpp" #include <vespa/searchlib/queryeval/wand/weak_and_search.h> namespace search::queryeval { @@ -243,11 +243,6 @@ AndBlueprint::createIntermediateSearch(const MultiSearch::Children &subSearches, return SearchIterator::UP(search); } -double -AndBlueprint::computeNextHitRate(const Blueprint & child, double hitRate) const { - return hitRate * child.hit_ratio(); -} - //----------------------------------------------------------------------------- Blueprint::HitEstimate diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h index 3a6b5e1a31a..1034edb2f1e 100644 --- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h +++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h @@ -37,11 +37,6 @@ public: HitEstimate combine(const std::vector<HitEstimate> &data) const override; FieldSpecBaseList exposeFields() const override; void optimize_self() override; - -private: - double computeNextHitRate(const Blueprint & child, double hitRate) const override; - -public: Blueprint::UP get_replacement() override; void sort(std::vector<Blueprint*> &children) const override; bool inheritStrict(size_t i) const override; diff --git a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp index 94cec9a63c5..4fb1f44e156 100644 --- a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp @@ -87,7 +87,7 @@ struct FakeContext : attribute::ISearchContext { } unsigned int approximateHits() const override { return 0; } std::unique_ptr<SearchIterator> createIterator(fef::TermFieldMatchData *, bool) override { abort(); } - void fetchPostings(const ExecuteInfo &) override { } + void fetchPostings(bool) override { } bool valid() const override { return true; } search::Int64Range getAsIntegerTerm() const override { abort(); } const search::QueryTermUCS4 * queryTerm() const override { abort(); } diff --git a/searchlib/src/vespa/searchlib/queryeval/multisearch.h b/searchlib/src/vespa/searchlib/queryeval/multisearch.h index af96734b26a..4b4cd101e5a 100644 --- a/searchlib/src/vespa/searchlib/queryeval/multisearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/multisearch.h @@ -3,6 +3,7 @@ #pragma once #include "searchiterator.h" +#include <vector> struct MultiSearchRemoveTest; @@ -31,7 +32,7 @@ public: * this object takes ownership of the children. **/ MultiSearch(const Children & children); - virtual ~MultiSearch() override; + virtual ~MultiSearch(); const Children & getChildren() const { return _children; } virtual bool isAnd() const { return false; } virtual bool isAndNot() const { return false; } diff --git a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp index 8be6263221a..6a844a6bec0 100644 --- a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp @@ -3,7 +3,6 @@ #include "emptysearch.h" #include "nearest_neighbor_blueprint.h" #include "nearest_neighbor_iterator.h" -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/eval/tensor/dense/dense_tensor_view.h> #include <vespa/searchlib/tensor/dense_tensor_attribute.h> diff --git a/searchlib/src/vespa/searchlib/queryeval/orsearch.h b/searchlib/src/vespa/searchlib/queryeval/orsearch.h index e3d74573db8..d74348feb5e 100644 --- a/searchlib/src/vespa/searchlib/queryeval/orsearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/orsearch.h @@ -5,7 +5,8 @@ #include "multisearch.h" #include "unpackinfo.h" -namespace search::queryeval { +namespace search { +namespace queryeval { /** * A simple implementation of the Or search operation. @@ -30,4 +31,5 @@ private: bool isOr() const override { return true; } }; -} +} // namespace queryeval +} // namespace search diff --git a/searchlib/src/vespa/searchlib/queryeval/posting_info.h b/searchlib/src/vespa/searchlib/queryeval/posting_info.h index 40fb5652d0f..b7f386475d8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/posting_info.h +++ b/searchlib/src/vespa/searchlib/queryeval/posting_info.h @@ -2,6 +2,7 @@ #pragma once #include <cstdint> +#include <memory> namespace search::queryeval { @@ -29,6 +30,8 @@ private: int32_t _maxWeight; public: + typedef std::unique_ptr<MinMaxPostingInfo> UP; + typedef std::shared_ptr<MinMaxPostingInfo> SP; MinMaxPostingInfo(int32_t minWeight, int32_t maxWeight) : PostingInfo(), _minWeight(minWeight), diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp index 805d3246460..3fd08047922 100644 --- a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.cpp @@ -233,7 +233,7 @@ namespace { } -void PredicateBlueprint::fetchPostings(const ExecuteInfo &) { +void PredicateBlueprint::fetchPostings(bool) { const auto &interval_index = _index.getIntervalIndex(); const auto &bounds_index = _index.getBoundsIndex(); lookupPostingLists(_interval_dict_entries, _interval_vector_iterators, diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h index 3c85978798a..16b725cd4b0 100644 --- a/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/predicate_blueprint.h @@ -47,7 +47,7 @@ public: const query::PredicateQuery &query); ~PredicateBlueprint(); - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, diff --git a/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.cpp index 22a392ca208..8ca8ef0f102 100644 --- a/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.cpp @@ -2,7 +2,6 @@ #include "same_element_blueprint.h" #include "same_element_search.h" -#include "field_spec.hpp" #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/attribute/elementiterator.h> #include <vespa/vespalib/objects/visit.hpp> @@ -55,10 +54,10 @@ SameElementBlueprint::optimize_self() } void -SameElementBlueprint::fetchPostings(const ExecuteInfo &execInfo) +SameElementBlueprint::fetchPostings(bool strict) { for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(ExecuteInfo::create(execInfo.isStrict() && (i == 0), execInfo.hitRate())); + _terms[i]->fetchPostings(strict && (i == 0)); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.h index fc19abe4c5e..e6fe9f8929c 100644 --- a/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/same_element_blueprint.h @@ -35,7 +35,7 @@ public: void addTerm(Blueprint::UP term); void optimize_self() override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; std::unique_ptr<SameElementSearch> create_same_element_search(bool strict) const; SearchIteratorUP createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, diff --git a/searchlib/src/vespa/searchlib/queryeval/searchiterator.h b/searchlib/src/vespa/searchlib/queryeval/searchiterator.h index afc1bc8ce15..8ea45646af8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/searchiterator.h +++ b/searchlib/src/vespa/searchlib/queryeval/searchiterator.h @@ -4,6 +4,7 @@ #include "posting_info.h" #include "begin_and_end_id.h" +#include <vespa/searchlib/fef/termfieldmatchdataposition.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/trinary.h> #include <memory> diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp index 2c63c96695a..edb26fdb296 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp @@ -2,7 +2,6 @@ #include "simple_phrase_blueprint.h" #include "simple_phrase_search.h" -#include "field_spec.hpp" #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/vespalib/objects/visit.hpp> #include <algorithm> @@ -82,10 +81,10 @@ SimplePhraseBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmd void -SimplePhraseBlueprint::fetchPostings(const ExecuteInfo &execInfo) +SimplePhraseBlueprint::fetchPostings(bool strict) { for (auto & term : _terms) { - term->fetchPostings(execInfo); + term->fetchPostings(strict); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h index 0fb1599d68f..a09bc3f6c06 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h @@ -36,7 +36,7 @@ public: SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/test/eagerchild.h b/searchlib/src/vespa/searchlib/queryeval/test/eagerchild.h index 372e5f7b2d2..db3206ab8a6 100644 --- a/searchlib/src/vespa/searchlib/queryeval/test/eagerchild.h +++ b/searchlib/src/vespa/searchlib/queryeval/test/eagerchild.h @@ -3,7 +3,9 @@ #include <vespa/searchlib/queryeval/searchiterator.h> -namespace search::queryeval::test { +namespace search { +namespace queryeval { +namespace test { /** * Child iterator that has initial docid > 0. @@ -15,4 +17,7 @@ struct EagerChild : public SearchIterator void doUnpack(uint32_t) override {} }; -} +} // namespace test +} // namespace queryeval +} // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/test/leafspec.h b/searchlib/src/vespa/searchlib/queryeval/test/leafspec.h index 47b5ed26b60..b1e3c31e8c4 100644 --- a/searchlib/src/vespa/searchlib/queryeval/test/leafspec.h +++ b/searchlib/src/vespa/searchlib/queryeval/test/leafspec.h @@ -43,9 +43,9 @@ struct LeafSpec return *this; } SearchIterator *create(SearchHistory &hist, fef::TermFieldMatchData *tfmd) const { - if (search != nullptr) { + if (search != NULL) { return new TrackedSearch(name, hist, search); - } else if (tfmd != nullptr) { + } else if (tfmd != NULL) { return new TrackedSearch(name, hist, result, *tfmd, MinMaxPostingInfo(0, maxWeight)); } diff --git a/searchlib/src/vespa/searchlib/queryeval/test/searchhistory.h b/searchlib/src/vespa/searchlib/queryeval/test/searchhistory.h index 172d531e415..d57c1ff63cb 100644 --- a/searchlib/src/vespa/searchlib/queryeval/test/searchhistory.h +++ b/searchlib/src/vespa/searchlib/queryeval/test/searchhistory.h @@ -5,7 +5,9 @@ #include <string> #include <vector> -namespace search::queryeval::test { +namespace search { +namespace queryeval { +namespace test { /** * Seek and unpack history for a search iterator. @@ -51,4 +53,7 @@ std::ostream &operator << (std::ostream &out, const SearchHistory &hist) { return out; } -} +} // namespace test +} // namespace queryeval +} // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/test/trackedsearch.h b/searchlib/src/vespa/searchlib/queryeval/test/trackedsearch.h index 6cb4c1a9dda..2fc5412a4a0 100644 --- a/searchlib/src/vespa/searchlib/queryeval/test/trackedsearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/test/trackedsearch.h @@ -16,11 +16,11 @@ namespace search::queryeval::test { class TrackedSearch : public SearchIterator { private: - std::string _name; - SearchHistory &_history; - fef::TermFieldMatchData _matchData; - SearchIterator::UP _search; - std::unique_ptr<MinMaxPostingInfo> _minMaxPostingInfo; + std::string _name; + SearchHistory &_history; + fef::TermFieldMatchData _matchData; + SearchIterator::UP _search; + MinMaxPostingInfo::UP _minMaxPostingInfo; static fef::TermFieldMatchDataArray makeArray(fef::TermFieldMatchData &match) { fef::TermFieldMatchDataArray array; 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 7ad4a36f871..bf98a9f5880 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 @@ -2,13 +2,13 @@ #include "wand_parts.h" #include "parallel_weak_and_blueprint.h" #include "parallel_weak_and_search.h" -#include <vespa/searchlib/queryeval/field_spec.hpp> -#include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> +#include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/vespalib/objects/visit.hpp> #include <algorithm> -namespace search::queryeval { +namespace search { +namespace queryeval { ParallelWeakAndBlueprint::ParallelWeakAndBlueprint(const FieldSpec &field, uint32_t scoresToTrack, @@ -78,7 +78,8 @@ ParallelWeakAndBlueprint::addTerm(Blueprint::UP term, int32_t weight) } SearchIterator::UP -ParallelWeakAndBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, bool strict) const +ParallelWeakAndBlueprint::createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, + bool strict) const { assert(tfmda.size() == 1); fef::MatchData::UP childrenMatchData = _layout.createMatchData(); @@ -102,11 +103,10 @@ ParallelWeakAndBlueprint::createLeafSearch(const search::fef::TermFieldMatchData } void -ParallelWeakAndBlueprint::fetchPostings(const ExecuteInfo & execInfo) +ParallelWeakAndBlueprint::fetchPostings(bool) { - ExecuteInfo childInfo = ExecuteInfo::create(true, execInfo.hitRate()); for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(childInfo); + _terms[i]->fetchPostings(true); } } @@ -124,4 +124,5 @@ 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 842067f9849..6bc4da64379 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,7 +9,8 @@ #include <memory> #include <vector> -namespace search::queryeval { +namespace search { +namespace queryeval { const uint32_t DEFAULT_PARALLEL_WAND_SCORES_ADJUST_FREQUENCY = 4; @@ -44,7 +45,7 @@ public: score_t scoreThreshold, double thresholdBoostFactor, uint32_t scoresAdjustFrequency); - virtual ~ParallelWeakAndBlueprint() override; + virtual ~ParallelWeakAndBlueprint(); const WeakAndHeap &getScores() const { return _scores; } @@ -60,8 +61,10 @@ public: SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void fetchPostings(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; bool always_needs_unpack() const override; }; -} +} // namespace queryeval +} // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.h b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.h index ba0812aad48..b561292d4ac 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.h @@ -68,7 +68,7 @@ struct ParallelWeakAndSearch : public SearchIterator static SearchIterator *createHeapWand(const Terms &terms, const MatchParams &matchParams, RankParams &&rankParams, bool strict); static SearchIterator *create(const Terms &terms, const MatchParams &matchParams, RankParams &&rankParams, bool strict); - static SearchIterator::UP create(fef::TermFieldMatchData &tmd, + static SearchIterator::UP create(search::fef::TermFieldMatchData &tmd, const MatchParams &matchParams, const std::vector<int32_t> &weights, const std::vector<IDocumentWeightAttribute::LookupResult> &dict_entries, 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 36378439c01..cec72129475 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp @@ -56,11 +56,11 @@ WeightedSetTermBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &t } void -WeightedSetTermBlueprint::fetchPostings(const ExecuteInfo &execInfo) +WeightedSetTermBlueprint::fetchPostings(bool strict) { - ExecuteInfo childInfo = ExecuteInfo::create(true, execInfo.hitRate()); + (void) strict; for (size_t i = 0; i < _terms.size(); ++i) { - _terms[i]->fetchPostings(childInfo); + _terms[i]->fetchPostings(true); } } 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 8ae42607a9d..19e88466b1a 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(const ExecuteInfo &execInfo) override; + void fetchPostings(bool strict) override; }; } diff --git a/searchlib/src/vespa/searchlib/test/CMakeLists.txt b/searchlib/src/vespa/searchlib/test/CMakeLists.txt index 41084148c87..1231a99920e 100644 --- a/searchlib/src/vespa/searchlib/test/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/test/CMakeLists.txt @@ -2,7 +2,6 @@ vespa_add_library(searchlib_test SOURCES document_weight_attribute_helper.cpp - imported_attribute_fixture.cpp initrange.cpp make_attribute_map_lookup_node.cpp mock_attribute_context.cpp diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp deleted file mode 100644 index 68d2dc5472b..00000000000 --- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "imported_attribute_fixture.h" -#include "mock_gid_to_lid_mapping.h" -#include <vespa/vespalib/util/stringfmt.h> -#include <future> - -namespace search { - -namespace { - struct MockReadGuard : public IDocumentMetaStoreContext::IReadGuard { - virtual const search::IDocumentMetaStore &get() const override { - search::IDocumentMetaStore *nullStore = nullptr; - return static_cast<search::IDocumentMetaStore &>(*nullStore); - } - }; -} - -IDocumentMetaStoreContext::IReadGuard::UP -MockDocumentMetaStoreContext::getReadGuard() const { - ++get_read_guard_cnt; - return std::make_unique<MockReadGuard>(); -} - -} - -namespace search::attribute { - -using document::DocumentId; -using document::GlobalId; -using DocId = IAttributeVector::DocId; -using WeightedInt = IAttributeVector::WeightedInt; -using WeightedFloat = IAttributeVector::WeightedFloat; -using WeightedString = IAttributeVector::WeightedString; -using WeightedConstChar = IAttributeVector::WeightedConstChar; -using WeightedEnum = IAttributeVector::WeightedEnum; -using test::MockGidToLidMapperFactory; - -std::shared_ptr<ReferenceAttribute> create_reference_attribute(vespalib::stringref name = "ref") { - return std::make_shared<ReferenceAttribute>(name, Config(BasicType::REFERENCE)); -} - -std::shared_ptr<MockDocumentMetaStoreContext> -create_target_document_meta_store() { - return std::make_shared<MockDocumentMetaStoreContext>(); -} - -std::shared_ptr<MockDocumentMetaStoreContext> -create_document_meta_store() { - return std::make_shared<MockDocumentMetaStoreContext>(); -} - -GlobalId dummy_gid(uint32_t doc_index) { - return DocumentId(vespalib::make_string("id:foo:bar::%u", doc_index)).getGlobalId(); -} - -std::unique_ptr<QueryTermSimple> word_term(vespalib::stringref term) { - return std::make_unique<QueryTermSimple>(term, QueryTermSimple::WORD); -} - - -void -ImportedAttributeFixture::map_reference(DocId from_lid, GlobalId via_gid, DocId to_lid) { - assert(from_lid < reference_attr->getNumDocs()); - mapper_factory->_map[via_gid] = to_lid; - if (to_lid != 0) { - reference_attr->notifyReferencedPut(via_gid, to_lid); - } else { - reference_attr->notifyReferencedRemove(via_gid); - } - reference_attr->update(from_lid, via_gid); - reference_attr->commit(); -} - - -std::shared_ptr<ImportedAttributeVector> -ImportedAttributeFixture::create_attribute_vector_from_members(vespalib::stringref name) { - return ImportedAttributeVectorFactory::create(name, reference_attr, document_meta_store, target_attr, target_document_meta_store, use_search_cache); -} - - -void -ImportedAttributeFixture::reset_with_new_target_attr(std::shared_ptr<AttributeVector> new_target) { - target_attr = std::move(new_target); - imported_attr = create_attribute_vector_from_members(); -} - - -void -ImportedAttributeFixture::set_up_attribute_vectors_before_adding_mappings() { - // Make a sneaky assumption that no tests try to use a lid > 9 - add_n_docs_with_undefined_values(*reference_attr, 10); - target_attr->addReservedDoc(); - add_n_docs_with_undefined_values(*target_attr, 10); -} - -ImportedAttributeFixture::ImportedAttributeFixture(bool use_search_cache_, FastSearchConfig fastSearch) - : use_search_cache(use_search_cache_), - target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32, fastSearch)), - target_document_meta_store(create_target_document_meta_store()), - reference_attr(create_reference_attribute()), - document_meta_store(create_document_meta_store()), - imported_attr(create_attribute_vector_from_members()), - mapper_factory(std::make_shared<MockGidToLidMapperFactory>()) -{ - reference_attr->setGidToLidMapperFactory(mapper_factory); -} - -ImportedAttributeFixture::~ImportedAttributeFixture() = default; - -bool has_active_enum_guards(AttributeVector &attr) { - return std::async(std::launch::async, [&attr] { return attr.hasActiveEnumGuards(); }).get(); -} - -} diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h index be6ff5b556d..bd888be0849 100644 --- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h +++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h @@ -2,8 +2,10 @@ #pragma once +#include "mock_gid_to_lid_mapping.h" #include "weighted_type_test_utils.h" #include <vespa/document/base/documentid.h> +#include <vespa/document/base/globalid.h> #include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/attributeguard.h> @@ -11,27 +13,43 @@ #include <vespa/searchlib/attribute/imported_attribute_vector.h> #include <vespa/searchlib/attribute/imported_attribute_vector_factory.h> #include <vespa/searchlib/attribute/integerbase.h> +#include <vespa/searchlib/attribute/not_implemented_attribute.h> #include <vespa/searchlib/attribute/reference_attribute.h> #include <vespa/searchlib/attribute/stringbase.h> #include <vespa/searchlib/common/i_document_meta_store_context.h> #include <vespa/searchlib/query/query_term_simple.h> #include <vespa/searchcommon/attribute/attributecontent.h> -#include <vespa/vespalib/testkit/test_kit.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/stringfmt.h> +#include <algorithm> +#include <future> +#include <map> +#include <memory> +#include <vector> namespace search { struct MockDocumentMetaStoreContext : public IDocumentMetaStoreContext { + + struct MockReadGuard : public IDocumentMetaStoreContext::IReadGuard { + virtual const search::IDocumentMetaStore &get() const override { + search::IDocumentMetaStore *nullStore = nullptr; + return static_cast<search::IDocumentMetaStore &>(*nullStore); + } + }; + mutable size_t get_read_guard_cnt; + using SP = std::shared_ptr<MockDocumentMetaStoreContext>; MockDocumentMetaStoreContext() : get_read_guard_cnt(0) {} - IReadGuard::UP getReadGuard() const override; -}; - -} -namespace search::attribute { + virtual IReadGuard::UP getReadGuard() const override { + ++get_read_guard_cnt; + return std::make_unique<MockReadGuard>(); + } +}; -namespace test { class MockGidToLidMapperFactory; } +namespace attribute { using document::DocumentId; using document::GlobalId; @@ -41,6 +59,19 @@ using WeightedFloat = IAttributeVector::WeightedFloat; using WeightedString = IAttributeVector::WeightedString; using WeightedConstChar = IAttributeVector::WeightedConstChar; using WeightedEnum = IAttributeVector::WeightedEnum; +using test::MockGidToLidMapperFactory; + +std::shared_ptr<ReferenceAttribute> create_reference_attribute(vespalib::stringref name = "ref") { + return std::make_shared<ReferenceAttribute>(name, Config(BasicType::REFERENCE)); +} + +MockDocumentMetaStoreContext::SP create_target_document_meta_store() { + return std::make_shared<MockDocumentMetaStoreContext>(); +} + +MockDocumentMetaStoreContext::SP create_document_meta_store() { + return std::make_shared<MockDocumentMetaStoreContext>(); +} enum class FastSearchConfig { ExplicitlyEnabled, @@ -105,8 +136,13 @@ void add_n_docs_with_undefined_values(VectorType &vec, size_t n) { vec.commit(); } -GlobalId dummy_gid(uint32_t doc_index); -std::unique_ptr<QueryTermSimple> word_term(vespalib::stringref term); +GlobalId dummy_gid(uint32_t doc_index) { + return DocumentId(vespalib::make_string("id:foo:bar::%u", doc_index)).getGlobalId(); +} + +std::unique_ptr<QueryTermSimple> word_term(vespalib::stringref term) { + return std::make_unique<QueryTermSimple>(term, QueryTermSimple::WORD); +} struct ReadGuardWrapper { std::unique_ptr<AttributeReadGuard> guard; @@ -118,13 +154,13 @@ struct ReadGuardWrapper { struct ImportedAttributeFixture { bool use_search_cache; std::shared_ptr<AttributeVector> target_attr; - std::shared_ptr<IDocumentMetaStoreContext> target_document_meta_store; + MockDocumentMetaStoreContext::SP target_document_meta_store; std::shared_ptr<ReferenceAttribute> reference_attr; - std::shared_ptr<MockDocumentMetaStoreContext> document_meta_store; + MockDocumentMetaStoreContext::SP document_meta_store; std::shared_ptr<ImportedAttributeVector> imported_attr; - std::shared_ptr<test::MockGidToLidMapperFactory> mapper_factory; + std::shared_ptr<MockGidToLidMapperFactory> mapper_factory; - ImportedAttributeFixture(bool use_search_cache_ = false, FastSearchConfig fastSearch = FastSearchConfig::Default); + ImportedAttributeFixture(bool use_search_cache_ = false); virtual ~ImportedAttributeFixture(); @@ -132,14 +168,26 @@ struct ImportedAttributeFixture { return ReadGuardWrapper(imported_attr->makeReadGuard(false)); } - void map_reference(DocId from_lid, GlobalId via_gid, DocId to_lid); + void map_reference(DocId from_lid, GlobalId via_gid, DocId to_lid) { + assert(from_lid < reference_attr->getNumDocs()); + mapper_factory->_map[via_gid] = to_lid; + if (to_lid != 0) { + reference_attr->notifyReferencedPut(via_gid, to_lid); + } else { + reference_attr->notifyReferencedRemove(via_gid); + } + reference_attr->update(from_lid, via_gid); + reference_attr->commit(); + } static vespalib::stringref default_imported_attr_name() { return "imported"; } std::shared_ptr<ImportedAttributeVector> - create_attribute_vector_from_members(vespalib::stringref name = default_imported_attr_name()); + create_attribute_vector_from_members(vespalib::stringref name = default_imported_attr_name()) { + return ImportedAttributeVectorFactory::create(name, reference_attr, document_meta_store, target_attr, target_document_meta_store, use_search_cache); + } template<typename AttrVecType> std::shared_ptr<AttrVecType> target_attr_as() { @@ -148,7 +196,10 @@ struct ImportedAttributeFixture { return ptr; } - void reset_with_new_target_attr(std::shared_ptr<AttributeVector> new_target); + void reset_with_new_target_attr(std::shared_ptr<AttributeVector> new_target) { + target_attr = std::move(new_target); + imported_attr = create_attribute_vector_from_members(); + } template<typename ValueType> struct LidToLidMapping { @@ -167,7 +218,12 @@ struct ImportedAttributeFixture { _value_in_target_attr(std::move(value_in_target_attr)) {} }; - void set_up_attribute_vectors_before_adding_mappings(); + void set_up_attribute_vectors_before_adding_mappings() { + // Make a sneaky assumption that no tests try to use a lid > 9 + add_n_docs_with_undefined_values(*reference_attr, 10); + target_attr->addReservedDoc(); + add_n_docs_with_undefined_values(*target_attr, 10); + } template<typename AttrVecType, typename MappingsType, typename ValueAssigner> void set_up_and_map(const MappingsType &mappings, ValueAssigner assigner) { @@ -230,6 +286,19 @@ struct ImportedAttributeFixture { } }; +ImportedAttributeFixture::ImportedAttributeFixture(bool use_search_cache_) + : use_search_cache(use_search_cache_), + target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32)), + target_document_meta_store(create_target_document_meta_store()), + reference_attr(create_reference_attribute()), + document_meta_store(create_document_meta_store()), + imported_attr(create_attribute_vector_from_members()), + mapper_factory(std::make_shared<MockGidToLidMapperFactory>()) { + reference_attr->setGidToLidMapperFactory(mapper_factory); +} + +ImportedAttributeFixture::~ImportedAttributeFixture() = default; + template<typename AttrValueType, typename PredicateType> void assert_multi_value_matches(const ImportedAttributeFixture &f, DocId lid, @@ -283,6 +352,9 @@ void reset_with_wset_value_reference_mappings( f.reset_with_wset_value_reference_mappings<AttrVecType, WeightedValueType>(type, mappings, fast_search); } -bool has_active_enum_guards(AttributeVector &attr); - +bool has_active_enum_guards(AttributeVector &attr) { + return std::async(std::launch::async, [&attr] { return attr.hasActiveEnumGuards(); }).get(); } + +} // attribute +} // search diff --git a/searchlib/src/vespa/searchlib/test/mock_gid_to_lid_mapping.h b/searchlib/src/vespa/searchlib/test/mock_gid_to_lid_mapping.h index 3f6a136b5dc..df7fff18bca 100644 --- a/searchlib/src/vespa/searchlib/test/mock_gid_to_lid_mapping.h +++ b/searchlib/src/vespa/searchlib/test/mock_gid_to_lid_mapping.h @@ -7,7 +7,9 @@ #include <map> #include <memory> -namespace search::attribute::test { +namespace search { +namespace attribute { +namespace test { using MockGidToLidMap = std::map<document::GlobalId, uint32_t>; @@ -36,4 +38,6 @@ struct MockGidToLidMapperFactory : public search::IGidToLidMapperFactory { } }; -} +} // test +} // attribute +} // search |