diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-05 11:41:12 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-05 12:17:04 +0000 |
commit | 885a066cfdddfd8c0c1edb23c754171f0d6e0ed6 (patch) | |
tree | 6360e1f7e5309b18e499b7a3068999a96b38147e /searchcore | |
parent | 4ca57c3bc062bda152157a9286210509f9987af4 (diff) |
Wire the trace object through.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp index 8fcb30a4143..0cb50fb00b0 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp @@ -2,9 +2,12 @@ #include "matchengine.h" #include <vespa/searchcore/proton/common/state_reporter_utils.h> #include <vespa/vespalib/data/slime/cursor.h> -#include <algorithm> +#include <vespa/vespalib/data/smart_buffer.h> +#include <vespa/vespalib/data/slime/binary_format.h> +#include <vespa/vespalib/stllike/asciistream.h> #include <vespa/log/log.h> + LOG_SETUP(".proton.matchengine.matchengine"); namespace { @@ -113,9 +116,9 @@ void MatchEngine::performSearch(search::engine::SearchRequest::Source req, search::engine::SearchClient &client) { - search::engine::SearchReply::UP ret(new search::engine::SearchReply); + auto ret = std::make_unique<search::engine::SearchReply>(); - if (req.get() != NULL) { + if (req.get()) { ISearchHandler::SP searchHandler; vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain(); { // try to find the match handler corresponding to the specified search doc type @@ -123,7 +126,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, DocTypeName docTypeName(*req.get()); searchHandler = _handlers.getHandler(docTypeName); } - if (searchHandler.get() != NULL) { + if (searchHandler) { ret = searchHandler->match(searchHandler, *req.get(), *threadBundle); } else { HandlerMap<ISearchHandler>::Snapshot::UP snapshot; @@ -140,6 +143,14 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, } ret->request = req.release(); ret->setDistributionKey(_distributionKey); + if (ret->request->getTraceLevel() > 0) { + vespalib::asciistream os; + os << "trace-" << _distributionKey; + search::fef::Properties & trace = ret->propertiesMap.lookupCreate(os.str()); + vespalib::SmartBuffer output(4096); + vespalib::slime::BinaryFormat::encode(ret->request->trace().getRoot(), output); + trace.add("slime", output.obtain().make_stringref()); + } client.searchDone(std::move(ret)); } |