From 8b9edb6f9fe919d825d73f794b57710ff4cec040 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 3 Jan 2020 10:18:34 +0100 Subject: Revert "Revert "Balder/add executeinfo"" --- .../imported_search_context/CMakeLists.txt | 1 + .../imported_search_context_test.cpp | 61 ++++++++++++++-------- 2 files changed, 40 insertions(+), 22 deletions(-) (limited to 'searchlib/src/tests/attribute/imported_search_context') 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 -#include #include #include #include #include #include #include +#include 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 create_context(std::unique_ptr term) { + std::unique_ptr + create_context(std::unique_ptr term) { return std::make_unique(std::move(term), SearchContextParams(), *imported_attr, *target_attr); } - std::unique_ptr create_iterator( - ImportedSearchContext& ctx, - TermFieldMatchData& match, - bool strict) { + std::unique_ptr + 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 create_non_strict_iterator( - ImportedSearchContext& ctx, - TermFieldMatchData& match) { + std::unique_ptr + create_non_strict_iterator(ImportedSearchContext& ctx, TermFieldMatchData& match) { return create_iterator(ctx, match, false); } - std::unique_ptr create_strict_iterator( - ImportedSearchContext& ctx, - TermFieldMatchData& match) { + std::unique_ptr + 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( @@ -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)); -- cgit v1.2.3