summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/imported_search_context
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-01-03 10:18:34 +0100
committerGitHub <noreply@github.com>2020-01-03 10:18:34 +0100
commit8b9edb6f9fe919d825d73f794b57710ff4cec040 (patch)
treea1d5bdc3bb0ff9c28dce7994173b03737c509322 /searchlib/src/tests/attribute/imported_search_context
parent48c8e7ea5ae757fda8480ce3d045711f22adc9f2 (diff)
Revert "Revert "Balder/add executeinfo""
Diffstat (limited to 'searchlib/src/tests/attribute/imported_search_context')
-rw-r--r--searchlib/src/tests/attribute/imported_search_context/CMakeLists.txt1
-rw-r--r--searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp61
2 files changed, 40 insertions, 22 deletions
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));