chore: improve performance of mget operation (#2212)

Specifically, allocate only a single blob when returning multiple entries from a shard.
In addition, refactor and unify MGetResponse between string family code and ReplyBuilder code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-11-24 14:13:07 +02:00 committed by GitHub
parent dafdb9f4cf
commit 7d53d196aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 194 additions and 120 deletions

View file

@ -973,7 +973,7 @@ OpResult<vector<OptLong>> OpArrIndex(const OpArgs& op_args, string_view key,
}
// Returns string vector that represents the query result of each supplied key.
vector<OptString> OpMGet(JsonExpression expression, const Transaction* t, EngineShard* shard) {
vector<OptString> OpJsonMGet(JsonExpression expression, const Transaction* t, EngineShard* shard) {
auto args = t->GetShardArgs(shard->shard_id());
DCHECK(!args.empty());
vector<OptString> response(args.size());
@ -1271,7 +1271,7 @@ void JsonFamily::MGet(CmdArgList args, ConnectionContext* cntx) {
auto cb = [&](Transaction* t, EngineShard* shard) {
ShardId sid = shard->shard_id();
mget_resp[sid] = OpMGet(ParseJsonPath(path, &ec), t, shard);
mget_resp[sid] = OpJsonMGet(ParseJsonPath(path, &ec), t, shard);
return OpStatus::OK;
};