Skip to content

Commit

Permalink
Support del mset mget exists in sharding mode (#729)
Browse files Browse the repository at this point in the history
* Support del mset mget exists in sharding mode

only one key is allowed in every single command
  • Loading branch information
whoiami authored Aug 16, 2019
1 parent 2496905 commit 336b901
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
12 changes: 12 additions & 0 deletions include/pika_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class DelCmd : public Cmd {
DelCmd(const std::string& name , int arity, uint16_t flag)
: Cmd(name, arity, flag) {};
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
virtual std::vector<std::string> current_key() const {
return keys_;
}

private:
std::vector<std::string> keys_;
virtual void DoInitial() override;
Expand Down Expand Up @@ -220,6 +224,10 @@ class MgetCmd : public Cmd {
MgetCmd(const std::string& name , int arity, uint16_t flag)
: Cmd(name, arity, flag) {};
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
virtual std::vector<std::string> current_key() const {
return keys_;
}

private:
std::vector<std::string> keys_;
virtual void DoInitial() override;
Expand Down Expand Up @@ -407,6 +415,10 @@ class ExistsCmd : public Cmd {
ExistsCmd(const std::string& name, int arity, uint16_t flag)
: Cmd(name, arity, flag) {}
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
virtual std::vector<std::string> current_key() const {
return keys_;
}

private:
std::vector<std::string> keys_;
virtual void DoInitial() override;
Expand Down
17 changes: 15 additions & 2 deletions include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ struct StatisticData {
uint64_t last_sec_thread_querynum;
uint64_t last_time_us;
};

static std::set<std::string> ShardingModeNotSupportCommands {kCmdNameDel,
/*
static std::set<std::string> MultiKvCommands {kCmdNameDel,
kCmdNameMget, kCmdNameKeys, kCmdNameMset,
kCmdNameMsetnx, kCmdNameExists, kCmdNameScan,
kCmdNameScanx, kCmdNamePKScanRange, kCmdNamePKRScanRange,
Expand All @@ -60,6 +60,19 @@ static std::set<std::string> ShardingModeNotSupportCommands {kCmdNameDel,
kCmdNamePfCount, kCmdNamePfMerge, kCmdNameGeoAdd,
kCmdNameGeoPos, kCmdNameGeoDist, kCmdNameGeoHash,
kCmdNameGeoRadius, kCmdNameGeoRadiusByMember};
*/

static std::set<std::string> ShardingModeNotSupportCommands {
kCmdNameMsetnx, kCmdNameScan, kCmdNameKeys,
kCmdNameScanx, kCmdNamePKScanRange, kCmdNamePKRScanRange,
kCmdNameRPopLPush, kCmdNameZUnionstore, kCmdNameZInterstore,
kCmdNameSUnion, kCmdNameSUnionstore, kCmdNameSInter,
kCmdNameSInterstore, kCmdNameSDiff, kCmdNameSDiffstore,
kCmdNameSMove, kCmdNameBitOp, kCmdNamePfAdd,
kCmdNamePfCount, kCmdNamePfMerge, kCmdNameGeoAdd,
kCmdNameGeoPos, kCmdNameGeoDist, kCmdNameGeoHash,
kCmdNameGeoRadius, kCmdNameGeoRadiusByMember};


extern PikaConf *g_pika_conf;

Expand Down
7 changes: 6 additions & 1 deletion src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,12 @@ void Cmd::ProcessSinglePartitionCmd() {
}

void Cmd::ProcessMultiPartitionCmd() {
LOG(INFO) << "Process Multi partition Cmd? -> " << name_;
if (argv_.size() == static_cast<size_t>(arity_ < 0 ? -arity_ : arity_)) {
ProcessSinglePartitionCmd();
} else {
res_.SetRes(CmdRes::kErrOther, "This command usage only support in classic mode\r\n");
return;
}
}

void Cmd::ProcessDoNotSpecifyPartitionCmd() {
Expand Down

0 comments on commit 336b901

Please sign in to comment.