diff options
author | Geir Storli <geirst@verizonmedia.com> | 2020-05-20 13:10:09 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2020-05-20 13:10:09 +0000 |
commit | 47e95a1a3506525c832517a4f8b0e925c9f12c02 (patch) | |
tree | 669e929e6f21741c880e95a131409c26241dbe19 /searchcore | |
parent | eb1e9294ad2c207f7c9b465f42d2b3de72fd336e (diff) |
Prepare to support matched-elements-only for arrays and weighted sets of primitive types.
This renames StructFieldMapper to MatchingElementsFields with added support for basic fields.
Also some terminology is aligned.
Diffstat (limited to 'searchcore')
7 files changed, 37 insertions, 37 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 00a319db394..9d5b67af81c 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -363,10 +363,10 @@ struct MyWorld { return docsum_matcher->get_rank_features(); } - MatchingElements::UP get_matching_elements(const DocsumRequest &req, const StructFieldMapper &mapper) { + MatchingElements::UP get_matching_elements(const DocsumRequest &req, const MatchingElementsFields &fields) { Matcher::SP matcher = createMatcher(); auto docsum_matcher = matcher->create_docsum_matcher(req, searchContext, attributeContext, *sessionManager); - return docsum_matcher->get_matching_elements(mapper); + return docsum_matcher->get_matching_elements(fields); } }; @@ -922,10 +922,10 @@ TEST("require that docsum matcher can extract matching elements from same elemen world.basicSetup(); world.add_same_element_results("foo", "bar"); auto request = world.create_docsum_request(make_same_element_stack_dump("foo", "bar"), {20}); - StructFieldMapper mapper; - mapper.add_mapping("my", "my.a1"); - mapper.add_mapping("my", "my.f1"); - auto result = world.get_matching_elements(*request, mapper); + MatchingElementsFields fields; + fields.add_mapping("my", "my.a1"); + fields.add_mapping("my", "my.f1"); + auto result = world.get_matching_elements(*request, fields); const auto &list = result->get_matching_elements(20, "my"); ASSERT_EQUAL(list.size(), 1u); EXPECT_EQUAL(list[0], 2u); @@ -936,10 +936,10 @@ TEST("require that docsum matcher can extract matching elements from single attr world.basicSetup(); world.add_same_element_results("foo", "bar"); auto request = world.create_docsum_request(make_simple_stack_dump("my.a1", "foo"), {20}); - StructFieldMapper mapper; - mapper.add_mapping("my", "my.a1"); - mapper.add_mapping("my", "my.f1"); - auto result = world.get_matching_elements(*request, mapper); + MatchingElementsFields fields; + fields.add_mapping("my", "my.a1"); + fields.add_mapping("my", "my.f1"); + auto result = world.get_matching_elements(*request, fields); const auto &list = result->get_matching_elements(20, "my"); ASSERT_EQUAL(list.size(), 2u); EXPECT_EQUAL(list[0], 2u); diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp index 872b4b27584..4fcd5aff4f9 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp @@ -214,10 +214,10 @@ DocsumContext::ParseLocation(search::docsummary::GetDocsumsState *state) } std::unique_ptr<MatchingElements> -DocsumContext::fill_matching_elements(const StructFieldMapper &struct_field_mapper) +DocsumContext::fill_matching_elements(const MatchingElementsFields &fields) { if (_matcher) { - return _matcher->get_matching_elements(_request, _searchCtx, _attrCtx, _sessionMgr, struct_field_mapper); + return _matcher->get_matching_elements(_request, _searchCtx, _attrCtx, _sessionMgr, fields); } return std::make_unique<MatchingElements>(); } diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h index 467add7face..1624048828f 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h +++ b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h @@ -53,7 +53,7 @@ public: void FillSummaryFeatures(search::docsummary::GetDocsumsState * state, search::docsummary::IDocsumEnvironment * env) override; void FillRankFeatures(search::docsummary::GetDocsumsState * state, search::docsummary::IDocsumEnvironment * env) override; void ParseLocation(search::docsummary::GetDocsumsState * state) override; - std::unique_ptr<search::MatchingElements> fill_matching_elements(const search::StructFieldMapper &struct_field_mapper) override; + std::unique_ptr<search::MatchingElements> fill_matching_elements(const search::MatchingElementsFields &fields) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp index a9f87cb249e..c8d0a572cd9 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp @@ -19,7 +19,7 @@ LOG_SETUP(".proton.matching.docsum_matcher"); using search::FeatureSet; using search::MatchingElements; -using search::StructFieldMapper; +using search::MatchingElementsFields; using search::fef::FeatureResolver; using search::fef::RankProgram; using search::queryeval::AndNotBlueprint; @@ -100,13 +100,13 @@ void find_matching_elements(const std::vector<uint32_t> &docs, const SameElement for (uint32_t i = 0; i < docs.size(); ++i) { search->find_matching_elements(docs[i], matches); if (!matches.empty()) { - result.add_matching_elements(docs[i], same_element.struct_field_name(), matches); + result.add_matching_elements(docs[i], same_element.field_name(), matches); matches.clear(); } } } -void find_matching_elements(const std::vector<uint32_t> &docs, const vespalib::string &struct_field_name, const AttrSearchCtx &attr_ctx, MatchingElements &result) { +void find_matching_elements(const std::vector<uint32_t> &docs, const vespalib::string &field_name, const AttrSearchCtx &attr_ctx, MatchingElements &result) { int32_t weight = 0; std::vector<uint32_t> matches; for (uint32_t i = 0; i < docs.size(); ++i) { @@ -114,26 +114,26 @@ void find_matching_elements(const std::vector<uint32_t> &docs, const vespalib::s matches.push_back(id); } if (!matches.empty()) { - result.add_matching_elements(docs[i], struct_field_name, matches); + result.add_matching_elements(docs[i], field_name, matches); matches.clear(); } } } -void find_matching_elements(const StructFieldMapper &mapper, const std::vector<uint32_t> &docs, const Blueprint &bp, MatchingElements &result) { +void find_matching_elements(const MatchingElementsFields &fields, const std::vector<uint32_t> &docs, const Blueprint &bp, MatchingElements &result) { if (auto same_element = as<SameElementBlueprint>(bp)) { - if (mapper.is_struct_field(same_element->struct_field_name())) { + if (fields.has_field(same_element->field_name())) { find_matching_elements(docs, *same_element, result); } } else if (const AttrSearchCtx *attr_ctx = bp.get_attribute_search_context()) { - if (mapper.is_struct_subfield(attr_ctx->attributeName())) { - find_matching_elements(docs, mapper.get_struct_field(attr_ctx->attributeName()), *attr_ctx, result); + if (fields.has_struct_field(attr_ctx->attributeName())) { + find_matching_elements(docs, fields.get_enclosing_field(attr_ctx->attributeName()), *attr_ctx, result); } } else if (auto and_not = as<AndNotBlueprint>(bp)) { - find_matching_elements(mapper, docs, and_not->getChild(0), result); + find_matching_elements(fields, docs, and_not->getChild(0), result); } else if (auto intermediate = as<IntermediateBlueprint>(bp)) { for (size_t i = 0; i < intermediate->childCnt(); ++i) { - find_matching_elements(mapper, docs, intermediate->getChild(i), result); + find_matching_elements(fields, docs, intermediate->getChild(i), result); } } } @@ -189,12 +189,12 @@ DocsumMatcher::get_rank_features() const } MatchingElements::UP -DocsumMatcher::get_matching_elements(const StructFieldMapper &field_mapper) const +DocsumMatcher::get_matching_elements(const MatchingElementsFields &fields) const { auto result = std::make_unique<MatchingElements>(); - if (_mtf && !field_mapper.empty()) { + if (_mtf && !fields.empty()) { if (const Blueprint *root = _mtf->query().peekRoot()) { - find_matching_elements(field_mapper, _docs, *root, *result); + find_matching_elements(fields, _docs, *root, *result); } } return result; diff --git a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.h b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.h index 7fdfbc1d2ba..2e2250c476c 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.h +++ b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.h @@ -3,8 +3,8 @@ #pragma once #include <vespa/searchlib/common/featureset.h> -#include <vespa/searchlib/common/struct_field_mapper.h> #include <vespa/searchlib/common/matching_elements.h> +#include <vespa/searchlib/common/matching_elements_fields.h> #include <vector> #include <memory> @@ -22,7 +22,7 @@ class DocsumMatcher { private: using FeatureSet = search::FeatureSet; - using StructFieldMapper = search::StructFieldMapper; + using MatchingElementsFields = search::MatchingElementsFields; using MatchingElements = search::MatchingElements; std::shared_ptr<SearchSession> _from_session; @@ -40,7 +40,7 @@ public: FeatureSet::UP get_summary_features() const; FeatureSet::UP get_rank_features() const; - MatchingElements::UP get_matching_elements(const StructFieldMapper &field_mapper) const; + MatchingElements::UP get_matching_elements(const MatchingElementsFields &fields) const; }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 630ac66f4f1..93b4f63060f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -27,7 +27,7 @@ using namespace search::grouping; using search::DocumentMetaData; using search::LidUsageStats; using search::FeatureSet; -using search::StructFieldMapper; +using search::MatchingElementsFields; using search::MatchingElements; using search::attribute::IAttributeContext; using search::fef::MatchDataLayout; @@ -336,10 +336,10 @@ Matcher::getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, MatchingElements::UP Matcher::get_matching_elements(const DocsumRequest &req, ISearchContext &search_ctx, IAttributeContext &attr_ctx, SessionManager &session_manager, - const StructFieldMapper &field_mapper) + const MatchingElementsFields &fields) { auto docsum_matcher = create_docsum_matcher(req, search_ctx, attr_ctx, session_manager); - return docsum_matcher->get_matching_elements(field_mapper); + return docsum_matcher->get_matching_elements(fields); } DocsumMatcher::UP diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.h b/searchcore/src/vespa/searchcore/proton/matching/matcher.h index 14562ffd6ca..243fdad63ae 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.h +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.h @@ -12,7 +12,7 @@ #include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/fef/blueprintfactory.h> #include <vespa/searchlib/common/featureset.h> -#include <vespa/searchlib/common/struct_field_mapper.h> +#include <vespa/searchlib/common/matching_elements_fields.h> #include <vespa/searchlib/common/matching_elements.h> #include <vespa/searchlib/common/resultset.h> #include <vespa/searchlib/queryeval/blueprint.h> @@ -54,8 +54,8 @@ private: using SearchRequest = search::engine::SearchRequest; using Properties = search::fef::Properties; using my_clock = std::chrono::steady_clock; - using StructFieldMapper = search::StructFieldMapper; using MatchingElements = search::MatchingElements; + using MatchingElementsFields = search::MatchingElementsFields; IndexEnvironment _indexEnv; search::fef::BlueprintFactory _blueprintFactory; std::shared_ptr<search::fef::RankSetup> _rankSetup; @@ -162,13 +162,13 @@ public: * @param search_ctx abstract view of searchable data * @param attr_ctx abstract view of attribute data * @param session_manager multilevel grouping session and query cache - * @param field_mapper knows which fields to collect information - * about and how they relate to each other + * @param fields knows which fields to collect information + * about and how they relate to each other * @return matching elements **/ MatchingElements::UP get_matching_elements(const DocsumRequest &req, ISearchContext &search_ctx, IAttributeContext &attr_ctx, SessionManager &session_manager, - const StructFieldMapper &field_mapper); + const MatchingElementsFields &fields); DocsumMatcher::UP create_docsum_matcher(const DocsumRequest &req, ISearchContext &search_ctx, IAttributeContext &attr_ctx, SessionManager &session_manager); |