diff options
Diffstat (limited to 'searchcore')
3 files changed, 20 insertions, 10 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp index ab1c8e3af49..fa5b95b8d72 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "handlerecorder.h" +#include <vespa/searchlib/fef/matchdata.h> #include <vespa/vespalib/stllike/asciistream.h> #include <algorithm> #include <cassert> @@ -8,6 +9,7 @@ #include <vespa/vespalib/stllike/hash_map_equal.hpp> #include <vespa/vespalib/util/array_equal.hpp> +using search::fef::MatchData; using search::fef::MatchDataDetails; using search::fef::TermFieldHandle; @@ -112,6 +114,20 @@ HandleRecorder::add(TermFieldHandle handle, } } +void +HandleRecorder::tag_match_data(MatchData &match_data) { + for (TermFieldHandle handle = 0; handle < match_data.getNumTermFields(); ++handle) { + auto &tfmd = *match_data.resolveTermField(handle); + auto recorded = _handles.find(handle); + if (recorded == _handles.end()) { + tfmd.tagAsNotNeeded(); + } else { + tfmd.setNeedNormalFeatures((static_cast<int>(recorded->second) & static_cast<int>(MatchDataDetails::Normal)) != 0); + tfmd.setNeedCheapFeatures((static_cast<int>(recorded->second) & static_cast<int>(MatchDataDetails::Cheap)) != 0); + } + } +} + } VESPALIB_HASH_MAP_INSTANTIATE(search::fef::TermFieldHandle, search::fef::MatchDataDetails); diff --git a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.h b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.h index 88a21fa5d7b..a114291b6bd 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.h +++ b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.h @@ -7,6 +7,8 @@ #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/util/noncopyable.hpp> +namespace search::fef { class MatchData; } + namespace proton::matching { /** @@ -37,6 +39,7 @@ public: static void register_handle(search::fef::TermFieldHandle handle, search::fef::MatchDataDetails requested_details); vespalib::string to_string() const; + void tag_match_data(search::fef::MatchData &match_data); private: void add(search::fef::TermFieldHandle handle, search::fef::MatchDataDetails requested_details); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index bc87ea11335..4a944dc3214 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -39,15 +39,6 @@ bool contains_all(const HandleRecorder::HandleMap &old_map, return true; } -void tag_match_data(const HandleRecorder::HandleMap &handles, MatchData &match_data) { - // TODO: Move tagging to separate component (for testing) and tag normal and cheap. - for (TermFieldHandle handle = 0; handle < match_data.getNumTermFields(); ++handle) { - if (handles.find(handle) == handles.end()) { - match_data.resolveTermField(handle)->tagAsNotNeeded(); - } - } -} - DegradationParams extractDegradationParams(const RankSetup &rankSetup, const Properties &rankProperties) { @@ -86,7 +77,7 @@ MatchTools::setup(search::fef::RankProgram::UP rank_program, double termwise_lim bool can_reuse_search = (_search && !_search_has_changed && contains_all(_used_handles, recorder.get_handles())); if (!can_reuse_search) { - tag_match_data(recorder.get_handles(), *_match_data); + recorder.tag_match_data(*_match_data); _match_data->set_termwise_limit(termwise_limit); _search = _query.createSearch(*_match_data); _used_handles = recorder.get_handles(); |