diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-01 21:41:30 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-01 21:41:30 +0000 |
commit | 4f5be349db2d4bef3f53be62fd7cbee9f8a8b9cd (patch) | |
tree | dab67ff4751470007081b5671adb47ce187aa846 /searchlib | |
parent | ce77fff993f6bab999bcf70cdcc255dbeb161d19 (diff) |
Consider estimated hitrate.
Diffstat (limited to 'searchlib')
6 files changed, 29 insertions, 6 deletions
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_search_context/imported_search_context_test.cpp b/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp index 1db013aaef3..53ad14f3c28 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 @@ -218,6 +218,24 @@ TEST_F("Strict iterator is marked as strict", Fixture) { 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) { + 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) { + 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>( diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp index 0251e9c945c..f146378782c 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp @@ -236,7 +236,9 @@ void ImportedSearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo _fetchPostingsDone = true; if (!_searchCacheLookup) { _target_search_context->fetchPostings(execInfo); - if (execInfo.isStrict() || _target_attribute.getIsFastSearch()) { + if (execInfo.isStrict() + || (_target_attribute.getIsFastSearch() && execInfo.hitRate() > 0.01)) + { makeMergedPostings(_target_attribute.getIsFilter()); considerAddSearchCacheEntry(); } diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp index b549876435f..598840b278e 100644 --- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp @@ -9,7 +9,12 @@ const ExecuteInfo ExecuteInfo::FALSE(true, 1.0); ExecuteInfo ExecuteInfo::create(bool strict) { - return ExecuteInfo(strict, 1.0); + 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 index 97e3d81a805..eba0c199efa 100644 --- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h +++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h @@ -20,6 +20,7 @@ public: static const ExecuteInfo TRUE; static const ExecuteInfo FALSE; static ExecuteInfo create(bool strict); + static ExecuteInfo create(bool strict, double HitRate); private: double _hitRate; bool _strict; diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h index bd888be0849..50d8030b779 100644 --- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h +++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h @@ -288,7 +288,7 @@ struct ImportedAttributeFixture { ImportedAttributeFixture::ImportedAttributeFixture(bool use_search_cache_) : use_search_cache(use_search_cache_), - target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32)), + target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32, FastSearchConfig::ExplicitlyEnabled)), target_document_meta_store(create_target_document_meta_store()), reference_attr(create_reference_attribute()), document_meta_store(create_document_meta_store()), |