aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2021-10-26 14:06:05 +0200
committerGitHub <noreply@github.com>2021-10-26 14:06:05 +0200
commit4c46aa8897fdcacefb5e3351487eb6b7f13033ce (patch)
treedd49e316ac5b065d9b33368620f59fccbe6a7779
parentc3b2e4d349b7eaa62a144c6431e927c7931b3114 (diff)
parentec0e803145a6dd8d0dd1757324ad38d4c6a78678 (diff)
Merge pull request #19721 from vespa-engine/arnej/remove-old-docsum-rpc
remove old docsum_by_slime RPC protocol
-rw-r--r--searchcore/src/tests/proton/summaryengine/summaryengine.cpp205
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.h3
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp34
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h9
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/CMakeLists.txt1
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.cpp140
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.h34
-rw-r--r--searchlib/src/vespa/searchlib/engine/docsumreply.h1
9 files changed, 7 insertions, 426 deletions
diff --git a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
index d942abd28c2..f82b4c9243f 100644
--- a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
+++ b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/searchcore/proton/summaryengine/summaryengine.h>
-#include <vespa/searchcore/proton/summaryengine/docsum_by_slime.h>
#include <vespa/searchlib/engine/searchreply.h>
#include <vespa/searchlib/util/rawbuf.h>
#include <vespa/searchlib/util/slime_output_raw_buf_adapter.h>
@@ -220,209 +220,6 @@ TEST("requireThatCorrectHandlerIsUsed") {
EXPECT_LESS(0.0, static_cast<metrics::DoubleAverageMetric *>(engine.getMetrics().getMetric("latency"))->getAverage());
}
-using vespalib::Slime;
-
-const char *GID1 = "abcdefghijkl";
-const char *GID2 = "bcdefghijklm";
-
-void
-verify(vespalib::stringref exp, const Slime &slime) {
- Memory expMemory(exp);
- vespalib::Slime expSlime;
- size_t used = vespalib::slime::JsonFormat::decode(expMemory, expSlime);
- EXPECT_TRUE(used > 0);
- EXPECT_EQUAL(expSlime, slime);
-}
-
-Slime
-createSlimeRequestLarger(size_t num,
- const vespalib::string & sessionId = vespalib::string(),
- const vespalib::string & ranking = vespalib::string(),
- const vespalib::string & docType = vespalib::string())
-{
- Slime r;
- Cursor &root = r.setObject();
- root.setString("class", "your-summary");
- if ( ! sessionId.empty()) {
- root.setData("sessionid", sessionId);
- }
- if (!ranking.empty()) {
- root.setString("ranking", ranking);
- }
- if (!docType.empty()) {
- root.setString("doctype", docType);
- }
- Cursor &array = root.setArray("gids");
- for (size_t i(0); i < num; i++) {
- array.addData(Memory(GID1, 12));
- array.addData(Memory(GID2, 12));
- }
- return r;
-}
-
-Slime
-createSlimeRequest(const vespalib::string & sessionId = vespalib::string(),
- const vespalib::string & ranking = vespalib::string(),
- const vespalib::string & docType = vespalib::string()) {
- return createSlimeRequestLarger(1, sessionId, ranking, docType);
-}
-
-TEST("requireThatSlimeRequestIsConvertedCorrectly") {
- vespalib::Slime slimeRequest = createSlimeRequest();
- TEST_DO(verify("{"
- " class: 'your-summary',"
- " gids: ["
- " x6162636465666768696A6B6C,"
- " x62636465666768696A6B6C6D"
- " ]"
- "}", slimeRequest));
- DocsumRequest::UP r = DocsumBySlime::slimeToRequest(slimeRequest.get());
- EXPECT_EQUAL("your-summary", r->resultClassName);
- EXPECT_FALSE(r->propertiesMap.cacheProperties().lookup("query").found());
- EXPECT_TRUE(r->sessionId.empty());
- EXPECT_TRUE(r->ranking.empty());
- EXPECT_EQUAL(2u, r->hits.size());
- EXPECT_EQUAL(GlobalId(GID1), r->hits[0].gid);
- EXPECT_EQUAL(GlobalId(GID2), r->hits[1].gid);
-}
-
-TEST("require that presence of sessionid affect both request.sessionid and enables cache") {
- vespalib::Slime slimeRequest = createSlimeRequest("1.some.key.7", "my-rank-profile");
- TEST_DO(verify("{"
- " class: 'your-summary',"
- " sessionid: x312E736F6D652E6B65792E37,"
- " ranking: 'my-rank-profile',"
- " gids: ["
- " x6162636465666768696A6B6C,"
- " x62636465666768696A6B6C6D"
- " ]"
- "}", slimeRequest));
- DocsumRequest::UP r = DocsumBySlime::slimeToRequest(slimeRequest.get());
- EXPECT_EQUAL("your-summary", r->resultClassName);
- EXPECT_EQUAL("my-rank-profile", r->ranking);
-
- EXPECT_EQUAL(0, strncmp("1.some.key.7", &r->sessionId[0],r->sessionId.size()));
- EXPECT_TRUE(r->propertiesMap.cacheProperties().lookup("query").found());
- EXPECT_EQUAL(2u, r->hits.size());
- EXPECT_EQUAL(GlobalId(GID1), r->hits[0].gid);
- EXPECT_EQUAL(GlobalId(GID2), r->hits[1].gid);
-}
-
-TEST("require that 'doctype' affects DocTypeName in a good way...") {
- vespalib::Slime slimeRequest = createSlimeRequest("1.some.key.7", "my-rank-profile", "my-document-type");
- TEST_DO(verify("{"
- " class: 'your-summary',"
- " sessionid: x312E736F6D652E6B65792E37,"
- " ranking: 'my-rank-profile',"
- " doctype: 'my-document-type',"
- " gids: ["
- " x6162636465666768696A6B6C,"
- " x62636465666768696A6B6C6D"
- " ]"
- "}", slimeRequest));
- DocsumRequest::UP r = DocsumBySlime::slimeToRequest(slimeRequest.get());
- EXPECT_EQUAL("your-summary", r->resultClassName);
- EXPECT_EQUAL("my-rank-profile", r->ranking);
-
- EXPECT_EQUAL(0, strncmp("1.some.key.7", &r->sessionId[0],r->sessionId.size()));
- EXPECT_TRUE(r->propertiesMap.cacheProperties().lookup("query").found());
- EXPECT_TRUE(r->propertiesMap.matchProperties().lookup("documentdb.searchdoctype").found());
- EXPECT_EQUAL(1u, r->propertiesMap.matchProperties().lookup("documentdb.searchdoctype").size());
- EXPECT_EQUAL("my-document-type", r->propertiesMap.matchProperties().lookup("documentdb.searchdoctype").get());
- EXPECT_EQUAL(DocTypeName("my-document-type").getName(), DocTypeName(*r).getName());
- EXPECT_EQUAL(2u, r->hits.size());
- EXPECT_EQUAL(GlobalId(GID1), r->hits[0].gid);
- EXPECT_EQUAL(GlobalId(GID2), r->hits[1].gid);
-}
-
-class Server {
-public:
- Server();
- ~Server();
-
-private:
- SummaryEngine engine;
- ISearchHandler::SP handler;
-public:
- DocsumBySlime docsumBySlime;
- DocsumByRPC docsumByRPC;
-};
-
-Server::Server()
- : engine(2),
- handler(std::make_shared<MySearchHandler>("slime", "some other value")),
- docsumBySlime(engine),
- docsumByRPC(docsumBySlime)
-{
- DocTypeName dtnvfoo("foo");
- engine.putSearchHandler(dtnvfoo, handler);
-}
-
-Server::~Server() = default;
-
-TEST("requireThatSlimeInterfaceWorksFine") {
- Server server;
- vespalib::Slime slimeRequest = createSlimeRequest();
- vespalib::Slime::UP response = server.docsumBySlime.getDocsums(slimeRequest.get());
- TEST_DO(verify(getAnswer(2, "some other value"), *response));
-}
-
-void
-verifyReply(size_t count, CompressionConfig::Type encoding, size_t orgSize, size_t compressedSize,
- FRT_RPCRequest *request) {
- FRT_Values &ret = *request->GetReturn();
- EXPECT_EQUAL(encoding, ret[0]._intval8);
- EXPECT_EQUAL(orgSize, ret[1]._intval32);
- EXPECT_EQUAL(compressedSize, ret[2]._data._len);
-
- DataBuffer uncompressed;
- ConstBufferRef blob(ret[2]._data._buf, ret[2]._data._len);
- vespalib::compression::decompress(CompressionConfig::toType(ret[0]._intval8), ret[1]._intval32,
- blob, uncompressed, false);
- EXPECT_EQUAL(orgSize, uncompressed.getDataLen());
-
- vespalib::Slime summaries;
- BinaryFormat::decode(Memory(uncompressed.getData(), uncompressed.getDataLen()), summaries);
- TEST_DO(verify(getAnswer(count, "some other value"), summaries));
-}
-
-void
-verifyRPC(size_t count,
- CompressionConfig::Type requestCompression, size_t requestSize, size_t requestBlobSize,
- CompressionConfig::Type replyCompression, size_t replySize, size_t replyBlobSize) {
- Server server;
- vespalib::Slime slimeRequest = createSlimeRequestLarger(count);
- vespalib::SimpleBuffer buf;
- BinaryFormat::encode(slimeRequest, buf);
- EXPECT_EQUAL(requestSize, buf.get().size);
-
- CompressionConfig config(requestCompression, 9, 100);
- DataBuffer compressed(const_cast<char *>(buf.get().data), buf.get().size);
- CompressionConfig::Type type = vespalib::compression::compress(config,
- ConstBufferRef(buf.get().data, buf.get().size),
- compressed, true);
- EXPECT_EQUAL(type, requestCompression);
-
- FRT_RPCRequest *request = new FRT_RPCRequest();
- FRT_Values &arg = *request->GetParams();
- arg.AddInt8(type);
- arg.AddInt32(buf.get().size);
- arg.AddData(compressed.getData(), compressed.getDataLen());
- EXPECT_EQUAL(requestBlobSize, compressed.getDataLen());
-
- server.docsumByRPC.getDocsums(*request);
- // note: createSlimeRequestLarger() inserts count * 2 gids
- verifyReply(count*2, replyCompression, replySize, replyBlobSize, request);
-
- request->SubRef();
-}
-
-TEST("requireThatRPCInterfaceWorks") {
- verifyRPC(1, CompressionConfig::NONE, 55, 55, CompressionConfig::NONE, 78, 78);
- verifyRPC(100, CompressionConfig::NONE, 2631, 2631, CompressionConfig::LZ4, 5030, 1057);
- verifyRPC(100, CompressionConfig::LZ4, 2631, 69, CompressionConfig::LZ4, 5030, 1057);
-}
-
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index 116ce072700..275f9029107 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -26,7 +26,6 @@
#include <vespa/searchcore/proton/matchengine/matchengine.h>
#include <vespa/searchcore/proton/persistenceengine/persistenceengine.h>
#include <vespa/searchcore/proton/reference/document_db_reference_registry.h>
-#include <vespa/searchcore/proton/summaryengine/docsum_by_slime.h>
#include <vespa/searchcore/proton/summaryengine/summaryengine.h>
#include <vespa/searchlib/common/packets.h>
#include <vespa/searchlib/transactionlog/trans_log_server_explorer.h>
@@ -226,7 +225,6 @@ Proton::Proton(const config::ConfigUri & configUri,
_documentDBMap(),
_matchEngine(),
_summaryEngine(),
- _docsumBySlime(),
_memoryFlushConfigUpdater(),
_flushEngine(),
_prepareRestartHandler(),
@@ -300,7 +298,6 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
_distributionKey = protonConfig.distributionkey;
_summaryEngine = std::make_unique<SummaryEngine>(protonConfig.numsummarythreads, protonConfig.docsum.async);
_summaryEngine->set_issue_forwarding(protonConfig.forwardIssues);
- _docsumBySlime = std::make_unique<DocsumBySlime>(*_summaryEngine);
IFlushStrategy::SP strategy;
const ProtonConfig::Flush & flush(protonConfig.flush);
@@ -351,8 +348,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
_prepareRestartHandler = std::make_unique<PrepareRestartHandler>(*_flushEngine);
RPCHooks::Params rpcParams(*this, protonConfig.rpcport, _configUri.getConfigId(),
- std::max(2u, computeRpcTransportThreads(protonConfig, hwInfo.cpu())),
- std::max(2u, hwInfo.cpu().cores()/4));
+ std::max(2u, computeRpcTransportThreads(protonConfig, hwInfo.cpu())));
rpcParams.slobrok_config = _configUri.createWithNewId(protonConfig.slobrokconfigid);
_rpcHooks = std::make_unique<RPCHooks>(rpcParams);
_metricsEngine->addExternalMetrics(_rpcHooks->proto_rpc_adapter_metrics());
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h
index 78dab7a61f6..6b0bef50cae 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.h
@@ -40,7 +40,6 @@ class IDocumentDBReferenceRegistry;
class IProtonDiskLayout;
class PrepareRestartHandler;
class SummaryEngine;
-class DocsumBySlime;
class FlushEngine;
class MatchEngine;
class PersistenceEngine;
@@ -89,7 +88,6 @@ private:
DocumentDBMap _documentDBMap;
std::unique_ptr<MatchEngine> _matchEngine;
std::unique_ptr<SummaryEngine> _summaryEngine;
- std::unique_ptr<DocsumBySlime> _docsumBySlime;
MemoryFlushConfigUpdater::UP _memoryFlushConfigUpdater;
std::unique_ptr<FlushEngine> _flushEngine;
std::unique_ptr<PrepareRestartHandler> _prepareRestartHandler;
@@ -192,7 +190,6 @@ public:
size_t getNumDocs() const;
size_t getNumActiveDocs() const;
- DocsumBySlime & getDocsumBySlime() { return *_docsumBySlime; }
search::engine::SearchServer &get_search_server();
search::engine::DocsumServer &get_docsum_server();
diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp
index 7a8cfe9b0d1..b7fb4ecdd92 100644
--- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp
@@ -2,7 +2,6 @@
#include "rpc_hooks.h"
#include "proton.h"
-#include <vespa/searchcore/proton/summaryengine/docsum_by_slime.h>
#include <vespa/searchcore/proton/matchengine/matchengine.h>
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -165,33 +164,21 @@ RPCHooksBase::initRPC()
rb.MethodDesc("Tell the node to prepare for a restart by flushing components "
"such that TLS replay time + time spent flushing components is as low as possible");
rb.ReturnDesc("success", "Whether or not prepare for restart was triggered.");
- //-------------------------------------------------------------------------
- rb.DefineMethod("proton.getDocsums", "bix", "bix", FRT_METHOD(RPCHooksBase::rpc_getDocSums), this);
- rb.MethodDesc("Get list of document summaries");
- rb.ParamDesc("encoding", "0=raw, 6=lz4");
- rb.ParamDesc("uncompressedBlobSize", "Uncompressed blob size");
- rb.ParamDesc("getDocsumX", "The request blob in slime");
- rb.ReturnDesc("encoding", "0=raw, 6=lz4");
- rb.ReturnDesc("uncompressedBlobSize", "Uncompressed blob size");
- rb.ReturnDesc("docsums", "Blob with slime encoded summaries.");
-
}
RPCHooksBase::Params::Params(Proton &parent, uint32_t port, const vespalib::string &ident,
- uint32_t transportThreads, uint32_t executorThreads)
+ uint32_t transportThreads)
: proton(parent),
slobrok_config(config::ConfigUri("client")),
identity(ident),
rtcPort(port),
- numTranportThreads(transportThreads),
- numDocsumRpcThreads(executorThreads)
+ numTranportThreads(transportThreads)
{ }
RPCHooksBase::Params::~Params() = default;
RPCHooksBase::RPCHooksBase(Params &params)
: _proton(params.proton),
- _docsumByRPC(std::make_unique<DocsumByRPC>(_proton.getDocsumBySlime())),
_transport(std::make_unique<FNET_Transport>(params.numTranportThreads)),
_orb(std::make_unique<FRT_Supervisor>(_transport.get())),
_proto_rpc_adapter(std::make_unique<ProtoRpcAdapter>(
@@ -201,7 +188,7 @@ RPCHooksBase::RPCHooksBase(Params &params)
_regAPI(*_orb, slobrok::ConfiguratorFactory(params.slobrok_config)),
_stateLock(),
_stateCond(),
- _executor(params.numDocsumRpcThreads, 128_Ki, proton_rpc_executor)
+ _executor(1u, 128_Ki, proton_rpc_executor)
{ }
void
@@ -390,21 +377,6 @@ RPCHooksBase::rpc_prepareRestart(FRT_RPCRequest *req)
letProtonDo(makeLambdaTask([this, req]() { prepareRestart(req); }));
}
-void
-RPCHooksBase::rpc_getDocSums(FRT_RPCRequest *req)
-{
- LOG(debug, "proton.getDocsums()");
- req->Detach();
- _executor.execute(makeLambdaTask([this, req]() { getDocsums(req); }));
-}
-
-void
-RPCHooksBase::getDocsums(FRT_RPCRequest *req)
-{
- _docsumByRPC->getDocsums(*req);
- req->Return();
-}
-
const RPCHooksBase::Session::SP &
RPCHooksBase::getSession(FRT_RPCRequest *req)
{
diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h
index 8dbb555830a..19805da6610 100644
--- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h
+++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h
@@ -15,7 +15,6 @@ class FNET_Transport;
namespace proton {
class Proton;
-class DocsumByRPC;
class RPCHooksBase : public FRT_Invokable
{
@@ -59,7 +58,6 @@ private:
};
Proton & _proton;
- std::unique_ptr<DocsumByRPC> _docsumByRPC;
std::unique_ptr<FNET_Transport> _transport;
std::unique_ptr<FRT_Supervisor> _orb;
std::unique_ptr<ProtoRpcAdapter> _proto_rpc_adapter;
@@ -76,7 +74,6 @@ private:
void checkState(std::unique_ptr<StateArg> arg);
void reportState(Session & session, FRT_RPCRequest * req) __attribute__((noinline));
void getProtonStatus(FRT_RPCRequest * req);
- void getDocsums(FRT_RPCRequest *req);
static const Session::SP & getSession(FRT_RPCRequest *req);
public:
@@ -87,12 +84,9 @@ public:
vespalib::string identity;
uint32_t rtcPort;
uint32_t numTranportThreads;
- // TODO: This can be eliminated and reduced to a fixed low number once old rpc has been removed from the qrs.
- // Or even use the shared executor
- uint32_t numDocsumRpcThreads;
Params(Proton &parent, uint32_t port, const vespalib::string &ident,
- uint32_t numTransportThreads, uint32_t numDocsumRpcThreads);
+ uint32_t numTransportThreads);
~Params();
};
RPCHooksBase(const RPCHooksBase &) = delete;
@@ -110,7 +104,6 @@ public:
void rpc_die(FRT_RPCRequest *req);
void rpc_triggerFlush(FRT_RPCRequest *req);
void rpc_prepareRestart(FRT_RPCRequest *req);
- void rpc_getDocSums(FRT_RPCRequest *req);
void initSession(FRT_RPCRequest *req);
void finiSession(FRT_RPCRequest *req);
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/summaryengine/CMakeLists.txt
index e2aa87ddacd..5b4066e4a53 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/CMakeLists.txt
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/CMakeLists.txt
@@ -2,6 +2,5 @@
vespa_add_library(searchcore_summaryengine STATIC
SOURCES
summaryengine.cpp
- docsum_by_slime.cpp
DEPENDS
)
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.cpp
deleted file mode 100644
index a5ad7618c84..00000000000
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "docsum_by_slime.h"
-#include <vespa/fnet/frt/rpcrequest.h>
-#include <vespa/searchlib/common/packets.h>
-#include <vespa/searchlib/util/slime_output_raw_buf_adapter.h>
-#include <vespa/vespalib/data/databuffer.h>
-#include <vespa/vespalib/util/compressor.h>
-#include <vespa/vespalib/util/size_literals.h>
-
-#include <vespa/log/log.h>
-LOG_SETUP(".proton.summaryengine.docsum_by_slime");
-
-namespace proton {
-
-using search::engine::DocsumRequest;
-using search::engine::DocsumReply;
-using vespalib::slime::Inspector;
-using vespalib::slime::Cursor;
-using vespalib::slime::ObjectSymbolInserter;
-using vespalib::Memory;
-using vespalib::slime::Symbol;
-using vespalib::slime::BinaryFormat;
-using vespalib::slime::ArrayTraverser;
-using vespalib::DataBuffer;
-using vespalib::ConstBufferRef;
-using vespalib::compression::CompressionConfig;
-
-namespace {
-
-Memory SESSIONID("sessionid");
-Memory RANKING("ranking");
-Memory LOCATION("location");
-Memory SUMMARYCLASS("class");
-Memory DOCUMENTTYPE("doctype");
-Memory GIDS("gids");
-Memory DOCSUM("docsum");
-Memory DOCSUMS("docsums");
-
-class GidTraverser : public ArrayTraverser
-{
-public:
- GidTraverser(std::vector<DocsumRequest::Hit> & hits) : _hits(hits) { }
- void entry(size_t idx, const Inspector &inspector) override {
- (void) idx;
- Memory data(inspector.asData());
- assert(data.size >= document::GlobalId::LENGTH);
- _hits.emplace_back(document::GlobalId(data.data));
- }
-private:
- std::vector<DocsumRequest::Hit> & _hits;
-};
-
-CompressionConfig
-getCompressionConfig()
-{
- using search::fs4transport::FS4PersistentPacketStreamer;
- const FS4PersistentPacketStreamer & streamer = FS4PersistentPacketStreamer::Instance;
- return CompressionConfig(streamer.getCompressionType(), streamer.getCompressionLevel(), 80, streamer.getCompressionLimit());
-}
-
-}
-
-DocsumRequest::UP
-DocsumBySlime::slimeToRequest(const Inspector & request)
-{
- DocsumRequest::UP docsumRequest(std::make_unique<DocsumRequest>());
-
- docsumRequest->resultClassName = request[SUMMARYCLASS].asString().make_string();
-
- Memory m = request[SESSIONID].asData();
- if (m.size > 0) {
- docsumRequest->sessionId.resize(m.size);
- memcpy(&docsumRequest->sessionId[0], m.data, m.size);
- docsumRequest->propertiesMap.lookupCreate(search::MapNames::CACHES).add("query", "true");
- }
-
- Memory d = request[DOCUMENTTYPE].asString();
- if (d.size > 0) {
- docsumRequest->propertiesMap.lookupCreate(search::MapNames::MATCH).add("documentdb.searchdoctype", d.make_string());
- }
-
- docsumRequest->ranking = request[RANKING].asString().make_string();
- docsumRequest->location = request[LOCATION].asString().make_string();
- Inspector & gids = request[GIDS];
- docsumRequest->hits.reserve(gids.entries());
- GidTraverser gidFiller(docsumRequest->hits);
- gids.traverse(gidFiller);
-
- return docsumRequest;
-}
-
-vespalib::Slime::UP
-DocsumBySlime::getDocsums(const Inspector & req)
-{
- DocsumReply::UP reply = _docsumServer.getDocsums(slimeToRequest(req));
- if (reply && reply->hasResult()) {
- return reply->releaseSlime();
- } else {
- LOG(warning, "got <null> docsum reply from back-end");
- }
- return std::make_unique<vespalib::Slime>();
-}
-
-DocsumByRPC::DocsumByRPC(DocsumBySlime & slimeDocsumServer) :
- _slimeDocsumServer(slimeDocsumServer)
-{
-}
-
-void
-DocsumByRPC::getDocsums(FRT_RPCRequest & req)
-{
- using vespalib::compression::decompress;
- using vespalib::compression::compress;
- FRT_Values &arg = *req.GetParams();
- uint8_t encoding = arg[0]._intval8;
- uint32_t uncompressedSize = arg[1]._intval32;
- DataBuffer uncompressed(arg[2]._data._buf, arg[2]._data._len);
- ConstBufferRef blob(arg[2]._data._buf, arg[2]._data._len);
- decompress(CompressionConfig::toType(encoding), uncompressedSize, blob, uncompressed, true);
- assert(uncompressedSize == uncompressed.getDataLen());
- vespalib::Slime summariesToGet;
- BinaryFormat::decode(Memory(uncompressed.getData(), uncompressed.getDataLen()), summariesToGet);
-
- vespalib::Slime::UP summaries = _slimeDocsumServer.getDocsums(summariesToGet.get());
- assert(summaries); // Mandatory, not optional.
-
- search::RawBuf rbuf(4_Ki);
- search::SlimeOutputRawBufAdapter output(rbuf);
- BinaryFormat::encode(*summaries, output);
- ConstBufferRef buf(rbuf.GetDrainPos(), rbuf.GetUsedLen());
- DataBuffer compressed(rbuf.GetWritableDrainPos(0), rbuf.GetUsedLen());
- CompressionConfig::Type type = compress(getCompressionConfig(), buf, compressed, true);
-
- FRT_Values &ret = *req.GetReturn();
- ret.AddInt8(type);
- ret.AddInt32(buf.size());
- ret.AddData(compressed.getData(), compressed.getDataLen());
-}
-
-}
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.h b/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.h
deleted file mode 100644
index 8203870ac91..00000000000
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/docsum_by_slime.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include <vespa/searchlib/engine/docsumapi.h>
-#include <vespa/vespalib/data/slime/slime.h>
-
-class FRT_RPCRequest;
-
-namespace proton {
-
-class DocsumBySlime {
- using DocsumServer = search::engine::DocsumServer;
- using DocsumRequest = search::engine::DocsumRequest;
- using DocsumReply = search::engine::DocsumReply;
- using Inspector = vespalib::slime::Inspector;
-public:
- typedef std::unique_ptr<DocsumBySlime> UP;
- DocsumBySlime(DocsumServer & docsumServer) : _docsumServer(docsumServer) { }
- vespalib::Slime::UP getDocsums(const Inspector & req);
- static DocsumRequest::UP slimeToRequest(const Inspector & req);
-private:
- DocsumServer & _docsumServer;
-};
-
-class DocsumByRPC
-{
-public:
- DocsumByRPC(DocsumBySlime & slimeDocsumServer);
- void getDocsums(FRT_RPCRequest & req);
-private:
- DocsumBySlime & _slimeDocsumServer;
-};
-
-}
diff --git a/searchlib/src/vespa/searchlib/engine/docsumreply.h b/searchlib/src/vespa/searchlib/engine/docsumreply.h
index 0caa848e4ef..e9f2898bc82 100644
--- a/searchlib/src/vespa/searchlib/engine/docsumreply.h
+++ b/searchlib/src/vespa/searchlib/engine/docsumreply.h
@@ -49,6 +49,7 @@ public:
_issues = std::move(issues);
}
+ // only used by unit test:
std::unique_ptr<vespalib::Slime> releaseSlime();
vespalib::slime::Inspector & root() const;