diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-03 10:18:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-03 10:18:34 +0100 |
commit | 8b9edb6f9fe919d825d73f794b57710ff4cec040 (patch) | |
tree | a1d5bdc3bb0ff9c28dce7994173b03737c509322 /searchlib/src/tests | |
parent | 48c8e7ea5ae757fda8480ce3d045711f22adc9f2 (diff) |
Revert "Revert "Balder/add executeinfo""
Diffstat (limited to 'searchlib/src/tests')
31 files changed, 186 insertions, 135 deletions
diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h index 8ff6ba46e86..bcb70abc654 100644 --- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -6,6 +6,7 @@ #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> @@ -133,7 +134,7 @@ AttributeFindSearcher<T>::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(queryeval::ExecuteInfo::TRUE); std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true); std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -211,7 +212,7 @@ AttributeRangeSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(queryeval::ExecuteInfo::TRUE); std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true); std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs()); @@ -250,7 +251,7 @@ AttributePrefixSearcher::doRun() _attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()), attribute::SearchContextParams()); - searchContext->fetchPostings(true); + searchContext->fetchPostings(queryeval::ExecuteInfo::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 a8abf1ff4fe..24919fb2341 100644 --- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp @@ -17,6 +17,8 @@ #include <vespa/searchlib/parsequery/parse.h> #include <vespa/log/log.h> +#include <vespa/searchlib/queryeval/executeinfo.h> + LOG_SETUP("bitvector_test"); using search::AttributeFactory; @@ -454,7 +456,7 @@ BitVectorTest::checkSearch(AttributePtr v, bool checkStride) { TermFieldMatchData md; - sc->fetchPostings(true); + sc->fetchPostings(search::queryeval::ExecuteInfo::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 09cd186811d..bf829f6607a 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,6 +29,7 @@ #include <cmath> using search::AttributeFactory; +using search::AttributeVector; using search::AttributeMemoryFileBufferWriter; using search::BufferWriter; using search::FloatingPointAttribute; @@ -630,7 +631,7 @@ EnumeratedSaveTest::testReload(AttributePtr v0, TermFieldMatchData md; SearchContextPtr sc = getSearch<VectorType>(as<VectorType>(v)); - sc->fetchPostings(true); + sc->fetchPostings(search::queryeval::ExecuteInfo::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 7ad3227917b..3a885dda233 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -2,9 +2,6 @@ #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 2d29050aec1..3421bc34ca5 100644 --- a/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt +++ b/searchlib/src/tests/attribute/imported_attribute_vector/CMakeLists.txt @@ -4,5 +4,6 @@ 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 9558d09da85..b77671f3c6e 100644 --- a/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt +++ b/searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt @@ -4,5 +4,6 @@ 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 e8dbaefc2ba..1bc87ef0da5 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,31 +18,30 @@ using vespalib::Trinary; struct Fixture : ImportedAttributeFixture { - Fixture(bool useSearchCache = false) : ImportedAttributeFixture(useSearchCache) {} + Fixture(bool useSearchCache = false, FastSearchConfig fastSearch = FastSearchConfig::Default) + : ImportedAttributeFixture(useSearchCache, fastSearch) + {} - 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); } @@ -210,13 +209,31 @@ TEST_F("Non-strict iterator unpacks target match data for weighted set hit", Wse TEST_F("Strict iterator is marked as strict", Fixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::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>( @@ -232,7 +249,7 @@ struct SingleValueFixture : Fixture { TEST_F("Strict iterator seeks to first available hit LID", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -258,7 +275,7 @@ TEST_F("Strict iterator seeks to first available hit LID", SingleValueFixture) { TEST_F("Strict iterator unpacks target match data for single value hit", SingleValueFixture) { auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -270,7 +287,7 @@ TEST_F("Strict iterator unpacks target match data for single value hit", SingleV TEST_F("Strict iterator unpacks target match data for array hit", ArrayValueFixture) { auto ctx = f.create_context(word_term("1234")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -282,7 +299,7 @@ TEST_F("Strict iterator unpacks target match data for array hit", ArrayValueFixt TEST_F("Strict iterator unpacks target match data for weighted set hit", WsetValueFixture) { auto ctx = f.create_context(word_term("foo")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -293,7 +310,7 @@ TEST_F("Strict iterator unpacks target match data for weighted set hit", WsetVal TEST_F("Strict iterator handles seek outside of LID space", ArrayValueFixture) { auto ctx = f.create_context(word_term("1234")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match; auto iter = f.create_strict_iterator(*ctx, match); @@ -325,7 +342,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(true); + ctx->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData match1; auto iter1 = f.create_strict_iterator(*ctx, match1); @@ -380,7 +397,7 @@ TEST_F("Bit vector from search cache is used if found", SearchCacheFixture) f.imported_attr->getSearchCache()->insert("5678", makeSearchCacheEntry({2, 6}, f.get_imported_attr()->getNumDocs())); auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::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 @@ -399,7 +416,7 @@ TEST_F("Entry is inserted into search cache if bit vector posting list is used", { EXPECT_EQUAL(0u, f.imported_attr->getSearchCache()->size()); auto ctx = f.create_context(word_term("5678")); - ctx->fetchPostings(true); + ctx->fetchPostings(queryeval::ExecuteInfo::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 9b4c72e1027..0bb10bcdbe6 100644 --- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp +++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp @@ -10,6 +10,7 @@ #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> @@ -375,7 +376,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch<StringAttribute>(sa); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb))) return false; @@ -388,7 +389,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, StringAttribute & { TermFieldMatchData md; SearchContextPtr sc = getSearch<StringAttribute, std::string>(sa, key, false); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -400,7 +401,7 @@ PostingListAttributeTest::assertSearch(const std::string &exp, IntegerAttribute { TermFieldMatchData md; SearchContextPtr sc = getSearch<IntegerAttribute, int32_t>(ia, key, false); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = sc->createIterator(&md, true); if (!EXPECT_TRUE(assertIterator(exp, *sb, &md))) return false; @@ -478,7 +479,7 @@ PostingListAttributeTest::checkSearch(bool useBitVector, const AttributeVector & { SearchContextPtr sc = getSearch(vec, term, false, attribute::SearchContextParams().useBitVector(useBitVector)); EXPECT_FALSE( ! sc ); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); size_t approx = sc->approximateHits(); EXPECT_EQUAL(numHits, approx); if (docBegin == 0) { @@ -883,15 +884,14 @@ PostingListAttributeTest::testMinMax(AttributePtr &ptr1, uint32_t trimmed) { TermFieldMatchData md; SearchContextPtr sc = getSearch<VectorType>(as<VectorType>(ptr1)); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = sc->createIterator(&md, true); sb->initFullRange(); const PostingInfo *pi = sb->getPostingInfo(); - ASSERT_TRUE(pi != NULL); - const MinMaxPostingInfo *mmpi = - dynamic_cast<const MinMaxPostingInfo *>(pi); - ASSERT_TRUE(mmpi != NULL); + ASSERT_TRUE(pi != nullptr); + const MinMaxPostingInfo *mmpi = dynamic_cast<const MinMaxPostingInfo *>(pi); + ASSERT_TRUE(mmpi != nullptr); 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(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); sb = sc->createIterator(&md, true); sb->initFullRange(); pi = sb->getPostingInfo(); if (trimmed == 2) { - ASSERT_TRUE(pi == NULL); + ASSERT_TRUE(pi == nullptr); } else { - ASSERT_TRUE(pi != NULL); + ASSERT_TRUE(pi != nullptr); mmpi = dynamic_cast<const MinMaxPostingInfo *>(pi); - ASSERT_TRUE(mmpi != NULL); + ASSERT_TRUE(mmpi != nullptr); 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 7bd755a0f98..4818287b429 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.get() != nullptr); + ASSERT_TRUE(bp); Result result(bp->getState().estimate().estHits, bp->getState().estimate().empty); - bp->fetchPostings(strict); + bp->fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); SearchIterator::UP iterator = bp->createSearch(*match_data, strict); - ASSERT_TRUE(iterator.get() != nullptr); + ASSERT_TRUE(iterator); 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 f6a9df54be3..fe5014b6607 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(strict); + bp->fetchPostings(queryeval::ExecuteInfo::create(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(strict); + bp->fetchPostings(queryeval::ExecuteInfo::create(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 8a63f20822f..e9addae07b9 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -19,6 +19,7 @@ #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> @@ -119,7 +120,7 @@ do_search(const Node &node, IAttributeManager &attribute_manager, bool expect_at } else { EXPECT_TRUE(result->get_attribute_search_context() == nullptr); } - result->fetchPostings(true); + result->fetchPostings(queryeval::ExecuteInfo::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 b518d683409..7d4a2d63355 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -12,6 +12,7 @@ #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> @@ -204,7 +205,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(strict); + sc.fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); for (bool withElementId : {false, true}) { testSearchIteratorUnpacking(ptr, sc, extra, strict, withElementId); } @@ -439,7 +440,7 @@ SearchContextTest::performSearch(const V & vec, const T & term, QueryTermSimple: { TermFieldMatchData dummy; SearchContextPtr sc = getSearch(vec, term, termType); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, vec.getNumDocs()); return rs; @@ -495,7 +496,7 @@ SearchContextTest::testFind(const PostingList<V, T> & pl) { { // strict search iterator SearchContextPtr sc = getSearch(pl.getAttribute(), pl.getValue()); - sc->fetchPostings(true); + sc->fetchPostings(queryeval::ExecuteInfo::TRUE); TermFieldMatchData dummy; SearchBasePtr sb = sc->createIterator(&dummy, true); ResultSetPtr rs = performSearch(*sb, pl.getAttribute().getNumDocs()); @@ -624,7 +625,7 @@ public: ~Verifier() override; SearchIterator::UP create(bool strict) const override { - _sc->fetchPostings(strict); + _sc->fetchPostings(queryeval::ExecuteInfo::create(strict, 1.0)); auto search = _sc->createIterator(&_dummy, strict); if (_withElementId) { search = std::make_unique<attribute::ElementIterator>(std::move(search), *_sc, _dummy); @@ -741,7 +742,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with 3 hits - threeHits.fetchPostings(true); + threeHits.fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = threeHits.createIterator(&dummy, true); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -762,7 +763,7 @@ SearchContextTest::testStrictSearchIterator(SearchContext & threeHits, } { // search for value with no hits - noHits.fetchPostings(true); + noHits.fetchPostings(queryeval::ExecuteInfo::TRUE); SearchBasePtr sb = noHits.createIterator(&dummy, true); sb->initRange(1, noHits.attribute().getCommittedDocIdLimit()); ASSERT_TRUE(typeTester.matches(*sb)); @@ -780,7 +781,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, { TermFieldMatchData dummy; { // search for value with three hits - threeHits.fetchPostings(false); + threeHits.fetchPostings(queryeval::ExecuteInfo::FALSE); SearchBasePtr sb = threeHits.createIterator(&dummy, false); sb->initRange(1, threeHits.attribute().getCommittedDocIdLimit()); EXPECT_TRUE(typeTester.matches(*sb)); @@ -798,7 +799,7 @@ SearchContextTest::testNonStrictSearchIterator(SearchContext & threeHits, EXPECT_TRUE(sb->getDocId() == 5u || sb->isAtEnd()); } { // search for value with no hits - noHits.fetchPostings(false); + noHits.fetchPostings(queryeval::ExecuteInfo::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 d34f824d094..243c24f6ab5 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(true); + b->fetchPostings(queryeval::ExecuteInfo::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(true); + b->fetchPostings(queryeval::ExecuteInfo::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(true); + b->fetchPostings(queryeval::ExecuteInfo::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,18 +297,15 @@ Test::requireThatBlueprintCanCreateSearchIterators() } { // posting list iterator b = _index->createBlueprint(_requestContext, FieldSpec("f1", 0, 0), makeTerm("w1")); - b->fetchPostings(true); + b->fetchPostings(queryeval::ExecuteInfo::TRUE); s = (dynamic_cast<LeafBlueprint *>(b.get()))->createLeafSearch(mda, true); ASSERT_TRUE((dynamic_cast<ZcRareWordPosOccIterator<true, false> *>(s.get()) != NULL)); } } -Test::Test() : - TestDiskIndex() -{ -} +Test::Test() = default; -Test::~Test() {} +Test::~Test() = default; 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 54124326507..71c7c93f756 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 a320c4a0641..4bb0f91659a 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(true); + result->fetchPostings(search::queryeval::ExecuteInfo::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(true); + res->fetchPostings(search::queryeval::ExecuteInfo::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 ce4864a4326..cb17ea35cf8 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() {} +MyTerm::~MyTerm() = default; class MyQuery { private: @@ -230,7 +230,7 @@ Test::testNearSearch(MyQuery &query, uint32_t matchId) } search::fef::MatchData::UP md(layout.createMatchData()); - bp->fetchPostings(true); + bp->fetchPostings(search::queryeval::ExecuteInfo::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 72a686fddda..6625a4a09ce 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(true); + const_cast<Blueprint &>(blueprint).fetchPostings(ExecuteInfo::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 9be238edba9..4aab1de06b3 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -1,31 +1,22 @@ // 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 <algorithm> +#include <vespa/log/log.h> +LOG_SETUP("blueprint_test"); using namespace search::queryeval; using namespace search::fef; @@ -37,6 +28,17 @@ 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); } @@ -86,6 +88,25 @@ 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 @@ -1047,7 +1068,7 @@ TEST("test WeakAnd Blueprint") { wa.addTerm(Blueprint::UP(new FakeBlueprint(field, z)), 140); wa.addTerm(Blueprint::UP(new FakeBlueprint(field, y)), 130); { - wa.fetchPostings(true); + wa.fetchPostings(ExecuteInfo::TRUE); SearchIterator::UP search = wa.createSearch(*md, true); EXPECT_TRUE(dynamic_cast<WeakAndSearch*>(search.get()) != 0); WeakAndSearch &s = dynamic_cast<WeakAndSearch&>(*search); @@ -1069,7 +1090,7 @@ TEST("test WeakAnd Blueprint") { EXPECT_EQUAL(0u, terms[2].maxScore); // NB: not set } { - wa.fetchPostings(false); + wa.fetchPostings(ExecuteInfo::FALSE); SearchIterator::UP search = wa.createSearch(*md, false); EXPECT_TRUE(dynamic_cast<WeakAndSearch*>(search.get()) != 0); EXPECT_TRUE(search->seek(1)); @@ -1099,7 +1120,7 @@ TEST("require_that_unpack_of_or_over_multisearch_is_optimized") { addChild(std::move(child1)). addChild(std::move(child2)))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::FALSE); EXPECT_EQUAL("search::queryeval::OrLikeSearch<false, search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1125,7 +1146,7 @@ TEST("require_that_unpack_of_or_is_optimized") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::FALSE); EXPECT_EQUAL("search::queryeval::OrLikeSearch<false, search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1144,7 +1165,7 @@ TEST("require_that_unpack_of_and_is_optimized") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::FALSE); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict<search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1164,7 +1185,7 @@ TEST("require_that_unpack_optimization_is_honoured_by_parents") { addChild(ap(MyLeafSpec(20).addField(2,2).create())). addChild(ap(MyLeafSpec(10).addField(3,3).create())))))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::FALSE); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict<search::queryeval::(anonymous namespace)::FullUnpack>", top_up->createSearch(*md, false)->getClassName()); md->resolveTermField(2)->tagAsNotNeeded(); @@ -1213,7 +1234,7 @@ TEST("require that children does not optimize when parents refuse them to") { FieldSpec("f2", 2, idxth21), makeTerm("w2")), 1.0))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::FALSE); SearchIterator::UP search = top_up->createSearch(*md, true); EXPECT_EQUAL("search::queryeval::EquivImpl<true>", search->getClassName()); { @@ -1251,7 +1272,7 @@ TEST("require_that_unpack_optimization_is_overruled_by_equiv") { addChild(ap(MyLeafSpec(10).addField(3,idxth3).create()))), 1.0))); MatchData::UP md = MatchData::makeTestInstance(100, 10); - top_up->fetchPostings(false); + top_up->fetchPostings(ExecuteInfo::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 2209ab0bfec..dd1d57fc296 100644 --- a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp @@ -1,10 +1,12 @@ // 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/vespalib/objects/visit.h> +#include <vespa/searchlib/fef/matchdata.h> + +#include <vespa/log/log.h> +LOG_SETUP("blueprint_test"); using namespace search::queryeval; using namespace search::fef; @@ -27,7 +29,7 @@ Test::testEmptyBlueprint() EXPECT_EQUAL(1u, empty.getState().field(0).getFieldId()); EXPECT_EQUAL(11u, empty.getState().field(0).getHandle()); - empty.fetchPostings(true); + empty.fetchPostings(ExecuteInfo::TRUE); SearchIterator::UP search = empty.createSearch(*md, true); SimpleResult res; @@ -45,7 +47,7 @@ Test::testSimpleBlueprint() SimpleBlueprint simple(a); simple.tag("tag"); EXPECT_EQUAL("tag", simple.tag()); - simple.fetchPostings(true); + simple.fetchPostings(ExecuteInfo::TRUE); SearchIterator::UP search = simple.createSearch(*md, true); SimpleResult res; @@ -67,7 +69,7 @@ Test::testFakeBlueprint() TermFieldHandle handle = 0; FakeBlueprint orig(FieldSpec("<field>", fieldId, handle), fake); - orig.fetchPostings(true); + orig.fetchPostings(ExecuteInfo::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 dbd73b6f40e..82ef58147c3 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -1,8 +1,9 @@ // 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 { @@ -93,7 +94,7 @@ public: } } - virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override { + void visitMembers(vespalib::ObjectVisitor &visitor) const override { visit(visitor, "_tag", _tag); visit(visitor, "_isLeaf", _isLeaf); visit(visitor, "_isStrict", _isStrict); @@ -101,7 +102,7 @@ public: visit(visitor, "_handles", _handles); } - virtual ~MySearch() {} + ~MySearch() override {} }; //----------------------------------------------------------------------------- @@ -111,7 +112,7 @@ class MyLeaf : public SimpleLeafBlueprint typedef search::fef::TermFieldMatchDataArray TFMDA; public: - virtual SearchIterator::UP + SearchIterator::UP createLeafSearch(const TFMDA &tfmda, bool strict) const override { return SearchIterator::UP(new MySearch("leaf", tfmda, strict)); @@ -155,7 +156,11 @@ public: return *this; } MyLeaf *create() const { - MyLeaf *leaf = new MyLeaf(_fields); + return create<MyLeaf>(); + } + template<typename Leaf> + Leaf *create() const { + Leaf *leaf = new Leaf(_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 f1b6cd05772..7414e8b10f2 100644 --- a/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp +++ b/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp @@ -58,7 +58,7 @@ struct DP { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(ExecuteInfo::create(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 5dac26fec22..ecd1c8cd218 100644 --- a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp +++ b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp @@ -50,7 +50,7 @@ Test::testEquiv() bool strict = (i == 0); TEST_STATE(strict ? "strict" : "non-strict"); MatchData::UP md = MatchData::makeTestInstance(100, 10); - bp->fetchPostings(strict); + bp->fetchPostings(ExecuteInfo::create(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 6fc75c8e696..cbad6de25bb 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(strict); + bp->fetchPostings(ExecuteInfo::create(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(strict); + bp->fetchPostings(ExecuteInfo::create(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(strict); + bp->fetchPostings(ExecuteInfo::create(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(strict); + bp->fetchPostings(ExecuteInfo::create(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(strict); + bp->fetchPostings(ExecuteInfo::create(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(false); + bp->fetchPostings(ExecuteInfo::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(false); + bp->fetchPostings(ExecuteInfo::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 607e6100f90..7926a518317 100644 --- a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp +++ b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp @@ -175,7 +175,7 @@ struct WandBlueprintSpec Node::UP term = createNode(); Blueprint::UP bp = blueprint(searchable, field, *term); MatchData::UP md(MatchData::makeTestInstance(1, 1)); - bp->fetchPostings(true); + bp->fetchPostings(ExecuteInfo::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(true); + bp->fetchPostings(ExecuteInfo::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 c76873a50cd..28b0d103040 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp @@ -26,6 +26,7 @@ using search::query::Weight; using search::queryeval::FieldSpecBase; using search::queryeval::PredicateBlueprint; using search::queryeval::SearchIterator; +using search::queryeval::ExecuteInfo; namespace { @@ -137,7 +138,7 @@ TEST_F("require that blueprint can create search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(ExecuteInfo::TRUE); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -161,7 +162,7 @@ TEST_F("require that blueprint can create more advanced search", Fixture) { f.indexEmptyDocument(doc_id + 2); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(ExecuteInfo::TRUE); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -184,7 +185,7 @@ TEST_F("require that blueprint can create NOT search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(ExecuteInfo::TRUE); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -200,7 +201,7 @@ TEST_F("require that blueprint can create compressed NOT search", Fixture) { f.indexDocument(doc_id, annotations); PredicateBlueprint blueprint(f.field, f.guard(), f.query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(ExecuteInfo::TRUE); TermFieldMatchDataArray tfmda; SearchIterator::UP it = blueprint.createLeafSearch(tfmda, true); ASSERT_TRUE(it.get()); @@ -224,7 +225,7 @@ TEST_F("require that blueprint can set up search with subqueries", Fixture) { query.getTerm()->addFeature("key2", "value", 2); PredicateBlueprint blueprint(f.field, f.guard(), query); - blueprint.fetchPostings(true); + blueprint.fetchPostings(ExecuteInfo::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 56c6f7e1282..26e7095dd60 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(true); + and_b->fetchPostings(ExecuteInfo::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(true); + or_b->fetchPostings(ExecuteInfo::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(true); + andnot_b->fetchPostings(ExecuteInfo::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(true); + andnot_b->fetchPostings(ExecuteInfo::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(true); + and_b->fetchPostings(ExecuteInfo::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(true); + rank_b->fetchPostings(ExecuteInfo::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 a4ca1ade999..378e16480b8 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(strict); + result->fetchPostings(ExecuteInfo::create(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 0743ac8408d..abaae7e4333 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -138,12 +138,13 @@ public: void fetchPostings(bool useBlueprint) { + ExecuteInfo execInfo = ExecuteInfo::create(_strict); if (useBlueprint) { - _phrase.fetchPostings(_strict); + _phrase.fetchPostings(execInfo); return; } for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->fetchPostings(_strict); + _children[i]->fetchPostings(execInfo); } } diff --git a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp index 2cd687ab23a..64ff8898bb0 100644 --- a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp +++ b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp @@ -9,6 +9,7 @@ #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; @@ -73,7 +74,7 @@ TEST("test strictness") { blend_b->addChild(std::move(a_b)); blend_b->addChild(std::move(b_b)); Blueprint::UP bp(blend_b); - bp->fetchPostings(strict); + bp->fetchPostings(ExecuteInfo::create(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 9f4c0058b93..8d70daa4ca8 100644 --- a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp +++ b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp @@ -11,6 +11,7 @@ #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; @@ -81,15 +82,15 @@ struct MyBlueprint : SimpleLeafBlueprint { setEstimate(HitEstimate(hits.size(), hits.empty())); set_allow_termwise_eval(allow_termwise_eval); } - ~MyBlueprint(); + ~MyBlueprint() override; SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &, bool strict) const override { - return SearchIterator::UP(new MyTerm(hits, strict)); + return std::make_unique<MyTerm>(hits, strict); } }; -MyBlueprint::~MyBlueprint() {} +MyBlueprint::~MyBlueprint() = default; 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 78195f19427..85d2f3f4a37 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp +++ b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp @@ -66,7 +66,7 @@ struct WS { Node::UP node = createNode(); FieldSpecList fields = FieldSpecList().add(FieldSpec(field, fieldId, handle)); queryeval::Blueprint::UP bp = searchable.createBlueprint(requestContext, fields, *node); - bp->fetchPostings(strict); + bp->fetchPostings(ExecuteInfo::create(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(strict); + bp->fetchPostings(ExecuteInfo::create(strict)); SearchIterator::UP sb = bp->createSearch(*md, strict); sb->initFullRange(); FakeResult result; |