From c857ff98ad4b0056967fe5a7f007d9902f333bb3 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Mon, 2 Dec 2024 00:25:37 +0200 Subject: [PATCH] chore: update command interface for bitops, bloom, zset families (#4235) --- src/server/bitops_family.cc | 59 +++++---- src/server/bloom_family.cc | 45 +++---- src/server/bloom_family.h | 12 +- src/server/generic_family.h | 1 - src/server/zset_family.cc | 255 +++++++++++++++++++----------------- src/server/zset_family.h | 83 ++++++------ 6 files changed, 231 insertions(+), 224 deletions(-) diff --git a/src/server/bitops_family.cc b/src/server/bitops_family.cc index 2145f9179cca..1be55cfb03ba 100644 --- a/src/server/bitops_family.cc +++ b/src/server/bitops_family.cc @@ -39,13 +39,13 @@ using BitsStrVec = vector; // The following is the list of the functions that would handle the // commands that handle the bit operations -void BitPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void BitCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void BitField(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void BitFieldRo(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void BitOp(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void GetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); -void SetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); +void BitPos(CmdArgList args, const CommandContext& cmd_cntx); +void BitCount(CmdArgList args, const CommandContext& cmd_cntx); +void BitField(CmdArgList args, const CommandContext& cmd_cntx); +void BitFieldRo(CmdArgList args, const CommandContext& cmd_cntx); +void BitOp(CmdArgList args, const CommandContext& cmd_cntx); +void GetBit(CmdArgList args, const CommandContext& cmd_cntx); +void SetBit(CmdArgList args, const CommandContext& cmd_cntx); OpResult ReadValue(const DbContext& context, string_view key, EngineShard* shard); OpResult ReadValueBitsetAt(const OpArgs& op_args, string_view key, uint32_t offset); @@ -513,10 +513,10 @@ void HandleOpValueResult(const OpResult& result, SinkReplyBuilder* builder) { // ------------------------------------------------------------------------- // // Impl for the command functions -void BitPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BitPos(CmdArgList args, const CommandContext& cmd_cntx) { // Support for the command BITPOS // See details at https://redis.io/commands/bitpos/ - + auto* builder = cmd_cntx.rb; if (args.size() < 1 || args.size() > 5) { return builder->SendError(kSyntaxErr); } @@ -560,11 +560,11 @@ void BitPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { auto cb = [&](Transaction* t, EngineShard* shard) { return FindFirstBitWithValue(t->GetOpArgs(shard), key, value, start, end, as_bit); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); HandleOpValueResult(res, builder); } -void BitCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BitCount(CmdArgList args, const CommandContext& cmd_cntx) { // Support for the command BITCOUNT // See details at https://redis.io/commands/bitcount/ // Please note that if the key don't exists, it would return 0 @@ -577,14 +577,14 @@ void BitCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { : std::pair{0, std::numeric_limits::max()}; bool as_bit = parser.HasNext() ? parser.MapNext("BYTE", false, "BIT", true) : false; - + auto* builder = cmd_cntx.rb; if (!parser.Finalize()) { return builder->SendError(parser.Error()->MakeReply()); } auto cb = [&](Transaction* t, EngineShard* shard) { return CountBitsForValue(t->GetOpArgs(shard), key, start, end, as_bit); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); HandleOpValueResult(res, builder); } @@ -1111,19 +1111,19 @@ void BitFieldGeneric(CmdArgList args, bool read_only, Transaction* tx, SinkReply SendResults(*res, builder); } -void BitField(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - BitFieldGeneric(args, false, tx, builder); +void BitField(CmdArgList args, const CommandContext& cmd_cntx) { + BitFieldGeneric(args, false, cmd_cntx.tx, cmd_cntx.rb); } -void BitFieldRo(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - BitFieldGeneric(args, true, tx, builder); +void BitFieldRo(CmdArgList args, const CommandContext& cmd_cntx) { + BitFieldGeneric(args, true, cmd_cntx.tx, cmd_cntx.rb); } #ifndef __clang__ #pragma GCC diagnostic pop #endif -void BitOp(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BitOp(CmdArgList args, const CommandContext& cmd_cntx) { static const std::array BITOP_OP_NAMES{OR_OP_NAME, XOR_OP_NAME, AND_OP_NAME, NOT_OP_NAME}; string op = absl::AsciiStrToUpper(ArgS(args, 0)); @@ -1131,6 +1131,7 @@ void BitOp(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { bool illegal = std::none_of(BITOP_OP_NAMES.begin(), BITOP_OP_NAMES.end(), [&op](auto val) { return op == val; }); + auto* builder = cmd_cntx.rb; if (illegal || (op == NOT_OP_NAME && args.size() > 3)) { return builder->SendError(kSyntaxErr); // too many arguments } @@ -1155,12 +1156,12 @@ void BitOp(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { return OpStatus::OK; }; - tx->Execute(std::move(shard_bitop), false); // we still have more work to do + cmd_cntx.tx->Execute(std::move(shard_bitop), false); // we still have more work to do // All result from each shard const auto joined_results = CombineResultOp(result_set, op); // Second phase - save to target key if successful if (!joined_results) { - tx->Conclude(); + cmd_cntx.tx->Conclude(); builder->SendError(joined_results.status()); return; } else { @@ -1191,12 +1192,12 @@ void BitOp(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { return OpStatus::OK; }; - tx->Execute(std::move(store_cb), true); + cmd_cntx.tx->Execute(std::move(store_cb), true); builder->SendLong(op_result.size()); } } -void GetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void GetBit(CmdArgList args, const CommandContext& cmd_cntx) { // Support for the command "GETBIT key offset" // see https://redis.io/commands/getbit/ @@ -1204,16 +1205,16 @@ void GetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { string_view key = ArgS(args, 0); if (!absl::SimpleAtoi(ArgS(args, 1), &offset)) { - return builder->SendError(kInvalidIntErr); + return cmd_cntx.rb->SendError(kInvalidIntErr); } auto cb = [&](Transaction* t, EngineShard* shard) { return ReadValueBitsetAt(t->GetOpArgs(shard), key, offset); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); - HandleOpValueResult(res, builder); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); + HandleOpValueResult(res, cmd_cntx.rb); } -void SetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void SetBit(CmdArgList args, const CommandContext& cmd_cntx) { // Support for the command "SETBIT key offset new_value" // see https://redis.io/commands/setbit/ @@ -1221,15 +1222,15 @@ void SetBit(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { auto [key, offset, value] = parser.Next>(); if (auto err = parser.Error(); err) { - return builder->SendError(err->MakeReply()); + return cmd_cntx.rb->SendError(err->MakeReply()); } auto cb = [&](Transaction* t, EngineShard* shard) { return BitNewValue(t->GetOpArgs(shard), key, offset, value != 0); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); - HandleOpValueResult(res, builder); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); + HandleOpValueResult(res, cmd_cntx.rb); } // ------------------------------------------------------------------------- // diff --git a/src/server/bloom_family.cc b/src/server/bloom_family.cc index 98bfc3d78a28..3cff8c18f512 100644 --- a/src/server/bloom_family.cc +++ b/src/server/bloom_family.cc @@ -91,7 +91,7 @@ OpResult OpExists(const OpArgs& op_args, string_view key, CmdArgLi } // namespace -void BloomFamily::Reserve(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BloomFamily::Reserve(CmdArgList args, const CommandContext& cmd_cntx) { CmdArgParser parser(args); string_view key = parser.Next(); SbfParams params; @@ -99,23 +99,23 @@ void BloomFamily::Reserve(CmdArgList args, Transaction* tx, SinkReplyBuilder* bu tie(params.error, params.init_capacity) = parser.Next(); if (parser.Error()) - return builder->SendError(kSyntaxErr); + return cmd_cntx.rb->SendError(kSyntaxErr); if (!params.ok()) - return builder->SendError("error rate is out of range", kSyntaxErrType); + return cmd_cntx.rb->SendError("error rate is out of range", kSyntaxErrType); const auto cb = [&](Transaction* t, EngineShard* shard) { return OpReserve(params, t->GetOpArgs(shard), key); }; - OpStatus res = tx->ScheduleSingleHop(std::move(cb)); + OpStatus res = cmd_cntx.tx->ScheduleSingleHop(std::move(cb)); if (res == OpStatus::KEY_EXISTS) { - return builder->SendError("item exists"); + return cmd_cntx.rb->SendError("item exists"); } - return builder->SendError(res); + return cmd_cntx.rb->SendError(res); } -void BloomFamily::Add(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BloomFamily::Add(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); args.remove_prefix(1); @@ -123,30 +123,30 @@ void BloomFamily::Add(CmdArgList args, Transaction* tx, SinkReplyBuilder* builde return OpAdd(t->GetOpArgs(shard), key, args); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); OpStatus status = res.status(); if (res) { if (res->front()) - return builder->SendLong(*res->front()); + return cmd_cntx.rb->SendLong(*res->front()); else status = res->front().status(); } - return builder->SendError(status); + return cmd_cntx.rb->SendError(status); } -void BloomFamily::Exists(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BloomFamily::Exists(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); args.remove_prefix(1); const auto cb = [&](Transaction* t, EngineShard* shard) { return OpExists(t->GetOpArgs(shard), key, args); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); - return builder->SendLong(res ? res->front() : 0); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); + return cmd_cntx.rb->SendLong(res ? res->front() : 0); } -void BloomFamily::MAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BloomFamily::MAdd(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); args.remove_prefix(1); @@ -154,23 +154,24 @@ void BloomFamily::MAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* build return OpAdd(t->GetOpArgs(shard), key, args); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); + RedisReplyBuilder* rb = static_cast(cmd_cntx.rb); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (!res) { - return builder->SendError(res.status()); + return rb->SendError(res.status()); } const AddResult& add_res = *res; - RedisReplyBuilder* rb = static_cast(builder); + rb->StartArray(add_res.size()); for (const OpResult& val : add_res) { if (val) { - builder->SendLong(*val); + rb->SendLong(*val); } else { - builder->SendError(val.status()); + rb->SendError(val.status()); } } } -void BloomFamily::MExists(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void BloomFamily::MExists(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); args.remove_prefix(1); @@ -178,9 +179,9 @@ void BloomFamily::MExists(CmdArgList args, Transaction* tx, SinkReplyBuilder* bu return OpExists(t->GetOpArgs(shard), key, args); }; - OpResult res = tx->ScheduleSingleHopT(std::move(cb)); + OpResult res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); - RedisReplyBuilder* rb = static_cast(builder); + RedisReplyBuilder* rb = static_cast(cmd_cntx.rb); rb->StartArray(args.size()); for (size_t i = 0; i < args.size(); ++i) { rb->SendLong(res ? res->at(i) : 0); diff --git a/src/server/bloom_family.h b/src/server/bloom_family.h index 1bb109b48e2e..73b0a8a266f9 100644 --- a/src/server/bloom_family.h +++ b/src/server/bloom_family.h @@ -13,7 +13,7 @@ class SinkReplyBuilder; namespace dfly { class CommandRegistry; -class ConnectionContext; +struct CommandContext; class BloomFamily { public: @@ -22,11 +22,11 @@ class BloomFamily { private: using SinkReplyBuilder = facade::SinkReplyBuilder; - static void Reserve(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void Add(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void MAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void Exists(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void MExists(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); + static void Reserve(CmdArgList args, const CommandContext& cmd_cntx); + static void Add(CmdArgList args, const CommandContext& cmd_cntx); + static void MAdd(CmdArgList args, const CommandContext& cmd_cntx); + static void Exists(CmdArgList args, const CommandContext& cmd_cntx); + static void MExists(CmdArgList args, const CommandContext& cmd_cntx); }; } // namespace dfly diff --git a/src/server/generic_family.h b/src/server/generic_family.h index 1af6ddd8dacd..40af99bedfff 100644 --- a/src/server/generic_family.h +++ b/src/server/generic_family.h @@ -19,7 +19,6 @@ namespace dfly { using facade::CmdArgList; using facade::OpResult; -class ConnectionContext; class CommandRegistry; class Transaction; struct CommandContext; diff --git a/src/server/zset_family.cc b/src/server/zset_family.cc index 77c5aaf0d5dd..a7015cd5e27c 100644 --- a/src/server/zset_family.cc +++ b/src/server/zset_family.cc @@ -2061,17 +2061,15 @@ void ZRemRangeGeneric(string_view key, const ZSetFamily::ZRangeSpec& range_spec, } // namespace -void ZSetFamily::BZPopMin(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder, - ConnectionContext* cntx) { - BZPopMinMax(args, tx, builder, cntx, false); +void ZSetFamily::BZPopMin(CmdArgList args, const CommandContext& cmd_cntx) { + BZPopMinMax(args, cmd_cntx.tx, cmd_cntx.rb, cmd_cntx.conn_cntx, false); } -void ZSetFamily::BZPopMax(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder, - ConnectionContext* cntx) { - BZPopMinMax(args, tx, builder, cntx, true); +void ZSetFamily::BZPopMax(CmdArgList args, const CommandContext& cmd_cntx) { + BZPopMinMax(args, cmd_cntx.tx, cmd_cntx.rb, cmd_cntx.conn_cntx, true); } -void ZSetFamily::ZAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZAdd(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); ZParams zparams; @@ -2096,6 +2094,7 @@ void ZSetFamily::ZAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builde } } + auto* builder = cmd_cntx.rb; if ((args.size() - i) % 2 != 0) { builder->SendError(kSyntaxErr); return; @@ -2151,7 +2150,7 @@ void ZSetFamily::ZAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builde } members.emplace_back(val, member); } - DCHECK(tx); + DCHECK(cmd_cntx.tx); if (to_sort_fields) { if (num_members == 2) { // fix unique_members for this special case. @@ -2165,10 +2164,10 @@ void ZSetFamily::ZAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builde } absl::Span memb_sp{members.data(), members.size()}; - ZAddGeneric(key, zparams, memb_sp, tx, builder); + ZAddGeneric(key, zparams, memb_sp, cmd_cntx.tx, builder); } -void ZSetFamily::ZCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZCard(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); auto cb = [&](Transaction* t, EngineShard* shard) -> OpResult { @@ -2180,16 +2179,16 @@ void ZSetFamily::ZCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* build return find_res.value()->second.Size(); }; - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() == OpStatus::WRONG_TYPE) { - builder->SendError(kWrongTypeErr); + cmd_cntx.rb->SendError(kWrongTypeErr); return; } - builder->SendLong(result.value()); + cmd_cntx.rb->SendLong(result.value()); } -void ZSetFamily::ZCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZCount(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view min_s = ArgS(args, 1); @@ -2197,33 +2196,33 @@ void ZSetFamily::ZCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil ScoreInterval si; if (!ParseBound(min_s, &si.first) || !ParseBound(max_s, &si.second)) { - return builder->SendError(kFloatRangeErr); + return cmd_cntx.rb->SendError(kFloatRangeErr); } auto cb = [&](Transaction* t, EngineShard* shard) { return OpCount(t->GetOpArgs(shard), key, si); }; - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() == OpStatus::WRONG_TYPE) { - builder->SendError(kWrongTypeErr); + cmd_cntx.rb->SendError(kWrongTypeErr); } else { - builder->SendLong(*result); + cmd_cntx.rb->SendLong(*result); } } -void ZSetFamily::ZDiff(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZDiff(CmdArgList args, const CommandContext& cmd_cntx) { vector> maps(shard_set->size()); auto cb = [&](Transaction* t, EngineShard* shard) { maps[shard->shard_id()] = OpFetch(shard, t); return OpStatus::OK; }; - tx->ScheduleSingleHop(std::move(cb)); + cmd_cntx.tx->ScheduleSingleHop(std::move(cb)); const string_view key = ArgS(args, 1); const ShardId sid = Shard(key, maps.size()); - auto* rb = static_cast(builder); + auto* rb = static_cast(cmd_cntx.rb); // Extract the ScoredMap of the first key auto& sm = maps[sid]; if (sm.empty()) { @@ -2270,20 +2269,22 @@ void ZSetFamily::ZDiff(CmdArgList args, Transaction* tx, SinkReplyBuilder* build } } -void ZSetFamily::ZIncrBy(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZIncrBy(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view score_arg = ArgS(args, 1); ScoredMemberView scored_member; scored_member.second = ArgS(args, 2); + auto* rb = static_cast(cmd_cntx.rb); + if (!absl::SimpleAtod(score_arg, &scored_member.first)) { VLOG(1) << "Bad score:" << score_arg << "|"; - return builder->SendError(kInvalidFloatErr); + return rb->SendError(kInvalidFloatErr); } if (isnan(scored_member.first)) { - return builder->SendError(kScoreNaN); + return rb->SendError(kScoreNaN); } ZParams zparams; @@ -2293,33 +2294,34 @@ void ZSetFamily::ZIncrBy(CmdArgList args, Transaction* tx, SinkReplyBuilder* bui return OpAdd(t->GetOpArgs(shard), zparams, key, ScoredMemberSpan{&scored_member, 1}); }; - OpResult add_result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult add_result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (add_result.status() == OpStatus::WRONG_TYPE) { - return builder->SendError(kWrongTypeErr); + return rb->SendError(kWrongTypeErr); } - auto* rb = static_cast(builder); if (add_result.status() == OpStatus::SKIPPED) { return rb->SendNull(); } if (add_result->is_nan) { - return builder->SendError(kScoreNaN); + return rb->SendError(kScoreNaN); } rb->SendDouble(add_result->new_score); } -void ZSetFamily::ZInter(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZBooleanOperation(args, "zinter", false, false, tx, builder); +void ZSetFamily::ZInter(CmdArgList args, const CommandContext& cmd_cntx) { + ZBooleanOperation(args, "zinter", false, false, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZInterStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZBooleanOperation(args, "zinterstore", false, true, tx, builder); +void ZSetFamily::ZInterStore(CmdArgList args, const CommandContext& cmd_cntx) { + ZBooleanOperation(args, "zinterstore", false, true, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZInterCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZInterCard(CmdArgList args, const CommandContext& cmd_cntx) { unsigned num_keys; + auto* builder = cmd_cntx.rb; + if (!absl::SimpleAtoi(ArgS(args, 0), &num_keys)) { return builder->SendError(OpStatus::SYNTAX_ERR); } @@ -2340,7 +2342,7 @@ void ZSetFamily::ZInterCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* return OpStatus::OK; }; - tx->ScheduleSingleHop(std::move(cb)); + cmd_cntx.tx->ScheduleSingleHop(std::move(cb)); OpResult result = IntersectResults(maps, AggType::NOOP); if (!result) @@ -2352,15 +2354,15 @@ void ZSetFamily::ZInterCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder->SendLong(result.value().size()); } -void ZSetFamily::ZPopMax(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZPopMinMax(std::move(args), true, tx, builder); +void ZSetFamily::ZPopMax(CmdArgList args, const CommandContext& cmd_cntx) { + ZPopMinMax(std::move(args), true, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZPopMin(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZPopMinMax(std::move(args), false, tx, builder); +void ZSetFamily::ZPopMin(CmdArgList args, const CommandContext& cmd_cntx) { + ZPopMinMax(std::move(args), false, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZLexCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZLexCount(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view min_s = ArgS(args, 1); @@ -2368,126 +2370,129 @@ void ZSetFamily::ZLexCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* b LexInterval li; if (!ParseLexBound(min_s, &li.first) || !ParseLexBound(max_s, &li.second)) { - return builder->SendError(kLexRangeErr); + return cmd_cntx.rb->SendError(kLexRangeErr); } auto cb = [&](Transaction* t, EngineShard* shard) { return OpLexCount(t->GetOpArgs(shard), key, li); }; - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() == OpStatus::WRONG_TYPE) { - builder->SendError(kWrongTypeErr); + cmd_cntx.rb->SendError(kWrongTypeErr); } else { - builder->SendLong(*result); + cmd_cntx.rb->SendLong(*result); } } -void ZSetFamily::ZRange(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, RangeParams{}); +void ZSetFamily::ZRange(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, RangeParams{}); } -void ZSetFamily::ZRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRankGeneric(args, false, tx, builder); +void ZSetFamily::ZRank(CmdArgList args, const CommandContext& cmd_cntx) { + ZRankGeneric(args, false, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZRevRange(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, RangeParams{.reverse = true}); +void ZSetFamily::ZRevRange(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, RangeParams{.reverse = true}); } -void ZSetFamily::ZRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, RangeParams{.interval_type = RangeParams::SCORE}); +void ZSetFamily::ZRangeByScore(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, RangeParams{.interval_type = RangeParams::SCORE}); } -void ZSetFamily::ZRangeStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args.subspan(1), tx, builder, +void ZSetFamily::ZRangeStore(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args.subspan(1), cmd_cntx.tx, cmd_cntx.rb, RangeParams{.with_scores = true, .store_key = ArgS(args, 0)}); } -void ZSetFamily::ZRevRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, +void ZSetFamily::ZRevRangeByScore(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, RangeParams{.reverse = true, .interval_type = RangeParams::SCORE}); } -void ZSetFamily::ZRevRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRankGeneric(args, true, tx, builder); +void ZSetFamily::ZRevRank(CmdArgList args, const CommandContext& cmd_cntx) { + ZRankGeneric(args, true, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, RangeParams{.interval_type = RangeParams::LEX}); +void ZSetFamily::ZRangeByLex(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, RangeParams{.interval_type = RangeParams::LEX}); } -void ZSetFamily::ZRevRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZRangeGeneric(args, tx, builder, RangeParams{.reverse = true, .interval_type = RangeParams::LEX}); +void ZSetFamily::ZRevRangeByLex(CmdArgList args, const CommandContext& cmd_cntx) { + ZRangeGeneric(args, cmd_cntx.tx, cmd_cntx.rb, + RangeParams{.reverse = true, .interval_type = RangeParams::LEX}); } -void ZSetFamily::ZRemRangeByRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZRemRangeByRank(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view min_s = ArgS(args, 1); string_view max_s = ArgS(args, 2); IndexInterval ii; if (!SimpleAtoi(min_s, &ii.first) || !SimpleAtoi(max_s, &ii.second)) { - return builder->SendError(kInvalidIntErr); + return cmd_cntx.rb->SendError(kInvalidIntErr); } ZRangeSpec range_spec; range_spec.interval = ii; - ZRemRangeGeneric(key, range_spec, tx, builder); + ZRemRangeGeneric(key, range_spec, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZRemRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZRemRangeByScore(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view min_s = ArgS(args, 1); string_view max_s = ArgS(args, 2); ScoreInterval si; if (!ParseBound(min_s, &si.first) || !ParseBound(max_s, &si.second)) { - return builder->SendError(kFloatRangeErr); + return cmd_cntx.rb->SendError(kFloatRangeErr); } ZRangeSpec range_spec; range_spec.interval = si; - ZRemRangeGeneric(key, range_spec, tx, builder); + ZRemRangeGeneric(key, range_spec, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZRemRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZRemRangeByLex(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view min_s = ArgS(args, 1); string_view max_s = ArgS(args, 2); LexInterval li; if (!ParseLexBound(min_s, &li.first) || !ParseLexBound(max_s, &li.second)) { - return builder->SendError(kLexRangeErr); + return cmd_cntx.rb->SendError(kLexRangeErr); } ZRangeSpec range_spec; range_spec.interval = li; - ZRemRangeGeneric(key, range_spec, tx, builder); + ZRemRangeGeneric(key, range_spec, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZRem(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZRem(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); auto members = args.subspan(1); auto cb = [&](Transaction* t, EngineShard* shard) { return OpRem(t->GetOpArgs(shard), key, members); }; - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() == OpStatus::WRONG_TYPE) { - builder->SendError(kWrongTypeErr); + cmd_cntx.rb->SendError(kWrongTypeErr); } else { - builder->SendLong(*result); + cmd_cntx.rb->SendLong(*result); } } -void ZSetFamily::ZRandMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZRandMember(CmdArgList args, const CommandContext& cmd_cntx) { + auto* rb = static_cast(cmd_cntx.rb); + if (args.size() > 3) - return builder->SendError(WrongNumArgsError("ZRANDMEMBER")); + return rb->SendError(WrongNumArgsError("ZRANDMEMBER")); CmdArgParser parser{args}; string_view key = parser.Next(); @@ -2499,17 +2504,16 @@ void ZSetFamily::ZRandMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* params.with_scores = static_cast(parser.Check("WITHSCORES")); if (parser.HasNext()) - return builder->SendError(absl::StrCat("Unsupported option:", string_view(parser.Next()))); + return rb->SendError(absl::StrCat("Unsupported option:", string_view(parser.Next()))); if (auto err = parser.Error(); err) - return builder->SendError(err->MakeReply()); + return rb->SendError(err->MakeReply()); const auto cb = [&](Transaction* t, EngineShard* shard) { return OpRandMember(count, params, t->GetOpArgs(shard), key); }; - OpResult result = tx->ScheduleSingleHopT(cb); - auto* rb = static_cast(builder); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(cb); if (result) { rb->SendScoredArray(result.value(), params.with_scores); } else if (result.status() == OpStatus::KEY_NOTFOUND) { @@ -2519,11 +2523,11 @@ void ZSetFamily::ZRandMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* rb->SendNull(); } } else { - builder->SendError(result.status()); + rb->SendError(result.status()); } } -void ZSetFamily::ZScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZScore(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view member = ArgS(args, 1); @@ -2531,10 +2535,10 @@ void ZSetFamily::ZScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil return OpScore(t->GetOpArgs(shard), key, member); }; - auto* rb = static_cast(builder); - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + auto* rb = static_cast(cmd_cntx.rb); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() == OpStatus::WRONG_TYPE) { - builder->SendError(kWrongTypeErr); + rb->SendError(kWrongTypeErr); } else if (!result) { rb->SendNull(); } else { @@ -2542,13 +2546,14 @@ void ZSetFamily::ZScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil } } -void ZSetFamily::ZMScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - OpResult result = ZGetMembers(args, tx, builder); +void ZSetFamily::ZMScore(CmdArgList args, const CommandContext& cmd_cntx) { + auto* rb = static_cast(cmd_cntx.rb); + + OpResult result = ZGetMembers(args, cmd_cntx.tx, rb); if (result.status() == OpStatus::WRONG_TYPE) { - return builder->SendError(kWrongTypeErr); + return rb->SendError(kWrongTypeErr); } - auto* rb = static_cast(builder); rb->StartArray(result->size()); // Array return type. const MScoreResponse& array = result.value(); for (const auto& p : array) { @@ -2560,20 +2565,22 @@ void ZSetFamily::ZMScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* bui } } -void ZSetFamily::ZScan(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::ZScan(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); string_view token = ArgS(args, 1); uint64_t cursor = 0; + auto* rb = static_cast(cmd_cntx.rb); + if (!absl::SimpleAtoi(token, &cursor)) { - return builder->SendError("invalid cursor"); + return rb->SendError("invalid cursor"); } OpResult ops = ScanOpts::TryFrom(args.subspan(2)); if (!ops) { DVLOG(1) << "Scan invalid args - return " << ops << " to the user"; - return builder->SendError(ops.status()); + return rb->SendError(ops.status()); } ScanOpts scan_op = ops.value(); @@ -2581,8 +2588,7 @@ void ZSetFamily::ZScan(CmdArgList args, Transaction* tx, SinkReplyBuilder* build return OpScan(t->GetOpArgs(shard), key, &cursor, scan_op); }; - auto* rb = static_cast(builder); - OpResult result = tx->ScheduleSingleHopT(std::move(cb)); + OpResult result = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb)); if (result.status() != OpStatus::WRONG_TYPE) { rb->StartArray(2); rb->SendBulkString(absl::StrCat(cursor)); @@ -2591,19 +2597,19 @@ void ZSetFamily::ZScan(CmdArgList args, Transaction* tx, SinkReplyBuilder* build rb->SendBulkString(k); } } else { - builder->SendError(result.status()); + rb->SendError(result.status()); } } -void ZSetFamily::ZUnion(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZBooleanOperation(args, "zunion", true, false, tx, builder); +void ZSetFamily::ZUnion(CmdArgList args, const CommandContext& cmd_cntx) { + ZBooleanOperation(args, "zunion", true, false, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::ZUnionStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - ZBooleanOperation(args, "zunionstore", true, true, tx, builder); +void ZSetFamily::ZUnionStore(CmdArgList args, const CommandContext& cmd_cntx) { + ZBooleanOperation(args, "zunionstore", true, true, cmd_cntx.tx, cmd_cntx.rb); } -void ZSetFamily::GeoAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::GeoAdd(CmdArgList args, const CommandContext& cmd_cntx) { string_view key = ArgS(args, 0); ZParams zparams; @@ -2622,6 +2628,7 @@ void ZSetFamily::GeoAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil } } + auto* builder = cmd_cntx.rb; args.remove_prefix(i); if (args.empty() || args.size() % 3 != 0) { builder->SendError(kSyntaxErr); @@ -2655,20 +2662,21 @@ void ZSetFamily::GeoAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil members.emplace_back(bits, member); } - DCHECK(tx); + DCHECK(cmd_cntx.tx); absl::Span memb_sp{members.data(), members.size()}; - ZAddGeneric(key, zparams, memb_sp, tx, builder); + ZAddGeneric(key, zparams, memb_sp, cmd_cntx.tx, builder); } -void ZSetFamily::GeoHash(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - OpResult result = ZGetMembers(args, tx, builder); +void ZSetFamily::GeoHash(CmdArgList args, const CommandContext& cmd_cntx) { + auto* rb = static_cast(cmd_cntx.rb); + + OpResult result = ZGetMembers(args, cmd_cntx.tx, rb); if (result.status() == OpStatus::WRONG_TYPE) { - return builder->SendError(kWrongTypeErr); + return rb->SendError(kWrongTypeErr); } - auto* rb = static_cast(builder); rb->StartArray(result->size()); // Array return type. const MScoreResponse& arr = result.value(); @@ -2682,14 +2690,15 @@ void ZSetFamily::GeoHash(CmdArgList args, Transaction* tx, SinkReplyBuilder* bui } } -void ZSetFamily::GeoPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { - OpResult result = ZGetMembers(args, tx, builder); +void ZSetFamily::GeoPos(CmdArgList args, const CommandContext& cmd_cntx) { + auto* rb = static_cast(cmd_cntx.rb); + + OpResult result = ZGetMembers(args, cmd_cntx.tx, rb); if (result.status() != OpStatus::OK) { - return builder->SendError(result.status()); + return rb->SendError(result.status()); } - auto* rb = static_cast(builder); rb->StartArray(result->size()); // Array return type. const MScoreResponse& arr = result.value(); @@ -2705,33 +2714,34 @@ void ZSetFamily::GeoPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* buil } } -void ZSetFamily::GeoDist(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::GeoDist(CmdArgList args, const CommandContext& cmd_cntx) { double distance_multiplier = 1; + auto* rb = static_cast(cmd_cntx.rb); + if (args.size() == 4) { string unit = absl::AsciiStrToUpper(ArgS(args, 3)); distance_multiplier = ExtractUnit(unit); args.remove_suffix(1); if (distance_multiplier < 0) { - return builder->SendError("unsupported unit provided. please use M, KM, FT, MI"); + return rb->SendError("unsupported unit provided. please use M, KM, FT, MI"); } } else if (args.size() != 3) { - return builder->SendError(kSyntaxErr); + return rb->SendError(kSyntaxErr); } - OpResult result = ZGetMembers(args, tx, builder); + OpResult result = ZGetMembers(args, cmd_cntx.tx, rb); if (result.status() != OpStatus::OK) { - return builder->SendError(result.status()); + return rb->SendError(result.status()); } const MScoreResponse& arr = result.value(); if (arr.size() != 2) { - return builder->SendError(kSyntaxErr); + return rb->SendError(kSyntaxErr); } - auto* rb = static_cast(builder); double xyxy[4]; // 2 pairs of score holding 2 locations for (size_t i = 0; i < arr.size(); i++) { if (!ScoreToLongLat(arr[i], xyxy + (i * 2))) { @@ -2968,7 +2978,7 @@ void GeoSearchStoreGeneric(Transaction* tx, SinkReplyBuilder* builder, const Geo } } // namespace -void ZSetFamily::GeoSearch(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::GeoSearch(CmdArgList args, const CommandContext& cmd_cntx) { // parse arguments string_view key = ArgS(args, 0); GeoShape shape = {}; @@ -2979,7 +2989,7 @@ void ZSetFamily::GeoSearch(CmdArgList args, Transaction* tx, SinkReplyBuilder* b bool from_set = false; // BYRADIUS or BYBOX is set bool by_set = false; - + auto* builder = cmd_cntx.rb; for (size_t i = 1; i < args.size(); ++i) { string cur_arg = absl::AsciiStrToUpper(ArgS(args, i)); @@ -3095,10 +3105,10 @@ void ZSetFamily::GeoSearch(CmdArgList args, Transaction* tx, SinkReplyBuilder* b } // parsing completed - GeoSearchStoreGeneric(tx, builder, shape, key, member, geo_ops); + GeoSearchStoreGeneric(cmd_cntx.tx, builder, shape, key, member, geo_ops); } -void ZSetFamily::GeoRadiusByMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { +void ZSetFamily::GeoRadiusByMember(CmdArgList args, const CommandContext& cmd_cntx) { GeoShape shape = {}; GeoSearchOpts geo_ops; // parse arguments @@ -3106,6 +3116,7 @@ void ZSetFamily::GeoRadiusByMember(CmdArgList args, Transaction* tx, SinkReplyBu // member to latlong, set shape.xy string_view member = ArgS(args, 1); + auto* builder = cmd_cntx.rb; if (!ParseDouble(ArgS(args, 2), &shape.t.radius)) { return builder->SendError(kInvalidFloatErr); } @@ -3189,7 +3200,7 @@ void ZSetFamily::GeoRadiusByMember(CmdArgList args, Transaction* tx, SinkReplyBu } // parsing completed - GeoSearchStoreGeneric(tx, builder, shape, key, member, geo_ops); + GeoSearchStoreGeneric(cmd_cntx.tx, builder, shape, key, member, geo_ops); } #define HFUNC(x) SetHandler(&ZSetFamily::x) diff --git a/src/server/zset_family.h b/src/server/zset_family.h index 722331378e75..ec678597a791 100644 --- a/src/server/zset_family.h +++ b/src/server/zset_family.h @@ -15,9 +15,8 @@ class SinkReplyBuilder; namespace dfly { -class ConnectionContext; class CommandRegistry; -class Transaction; +struct CommandContext; class ZSetFamily { public: @@ -62,48 +61,44 @@ class ZSetFamily { template using OpResult = facade::OpResult; using SinkReplyBuilder = facade::SinkReplyBuilder; - static void BZPopMin(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder, - ConnectionContext* cntx); - static void BZPopMax(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder, - ConnectionContext* cntx); - - static void ZAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZDiff(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZIncrBy(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZInterStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZInter(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZInterCard(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZLexCount(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZPopMax(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZPopMin(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRange(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRem(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRandMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZMScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRevRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRangeStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRemRangeByRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRemRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRemRangeByLex(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRevRange(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRevRangeByScore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZRevRank(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZScan(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZUnion(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void ZUnionStore(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - - static void GeoAdd(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void GeoHash(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void GeoPos(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void GeoDist(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void GeoSearch(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); - static void GeoRadiusByMember(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder); + static void BZPopMin(CmdArgList args, const CommandContext& cmd_cntx); + static void BZPopMax(CmdArgList args, const CommandContext& cmd_cntx); + static void ZAdd(CmdArgList args, const CommandContext& cmd_cntx); + static void ZCard(CmdArgList args, const CommandContext& cmd_cntx); + static void ZCount(CmdArgList args, const CommandContext& cmd_cntx); + static void ZDiff(CmdArgList args, const CommandContext& cmd_cntx); + static void ZIncrBy(CmdArgList args, const CommandContext& cmd_cntx); + static void ZInterStore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZInter(CmdArgList args, const CommandContext& cmd_cntx); + static void ZInterCard(CmdArgList args, const CommandContext& cmd_cntx); + static void ZLexCount(CmdArgList args, const CommandContext& cmd_cntx); + static void ZPopMax(CmdArgList args, const CommandContext& cmd_cntx); + static void ZPopMin(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRange(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRank(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRem(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRandMember(CmdArgList args, const CommandContext& cmd_cntx); + static void ZScore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZMScore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRangeByLex(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRevRangeByLex(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRangeByScore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRangeStore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRemRangeByRank(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRemRangeByScore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRemRangeByLex(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRevRange(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRevRangeByScore(CmdArgList args, const CommandContext& cmd_cntx); + static void ZRevRank(CmdArgList args, const CommandContext& cmd_cntx); + static void ZScan(CmdArgList args, const CommandContext& cmd_cntx); + static void ZUnion(CmdArgList args, const CommandContext& cmd_cntx); + static void ZUnionStore(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoAdd(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoHash(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoPos(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoDist(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoSearch(CmdArgList args, const CommandContext& cmd_cntx); + static void GeoRadiusByMember(CmdArgList args, const CommandContext& cmd_cntx); }; } // namespace dfly