Skip to content

Commit

Permalink
fix migrate list slot logic (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
luky116 committed Jul 3, 2023
1 parent 694b18e commit 6f9f9ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/pika_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void LPopCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->LPop(key_, &value);
if (s.ok()) {
res_.AppendString(value);
AddSlotKey("l", key_, slot);
} else if (s.IsNotFound()) {
res_.AppendStringLen(-1);
} else {
Expand Down Expand Up @@ -190,7 +189,6 @@ void LRemCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->LRem(key_, count_, value_, &res);
if (s.ok() || s.IsNotFound()) {
res_.AppendInteger(res);
RemKeyNotExists("l", key_, slot);
} else {
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
Expand Down Expand Up @@ -261,7 +259,6 @@ void RPopCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->RPop(key_, &value);
if (s.ok()) {
res_.AppendString(value);
RemKeyNotExists("l", key_, slot);
} else if (s.IsNotFound()) {
res_.AppendStringLen(-1);
} else {
Expand All @@ -284,6 +281,7 @@ void RPopLPushCmd::Do(std::shared_ptr<Slot> slot) {
std::string value;
rocksdb::Status s = slot->db()->RPoplpush(source_, receiver_, &value);
if (s.ok()) {
AddSlotKey("k", receiver_, slot);
res_.AppendString(value);
value_poped_from_source_ = value;
is_write_binlog_ = true;
Expand Down Expand Up @@ -336,7 +334,7 @@ void RPushCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->RPush(key_, values_, &llen);
if (s.ok()) {
res_.AppendInteger(llen);
RemKeyNotExists("l", key_, slot);
AddSlotKey("l", key_, slot);
} else {
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
Expand All @@ -358,7 +356,7 @@ void RPushxCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->RPushx(key_, values_, &llen);
if (s.ok() || s.IsNotFound()) {
res_.AppendInteger(llen);
RemKeyNotExists("l", key_, slot);
AddSlotKey("l", key_, slot);
} else {
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
Expand Down
3 changes: 0 additions & 3 deletions src/pika_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void SPopCmd::Do(std::shared_ptr<Slot> slot) {
for (const auto& member : members) {
res_.AppendStringLen(member.size());
res_.AppendContent(member);
AddSlotKey("s", key_, slot);
}
} else if (s.IsNotFound()) {
res_.AppendContent("$-1");
Expand Down Expand Up @@ -185,7 +184,6 @@ void SRemCmd::Do(std::shared_ptr<Slot> slot) {
int32_t count = 0;
rocksdb::Status s = slot->db()->SRem(key_, members_, &count);
res_.AppendInteger(count);
AddSlotKey("s", key_, slot);
}

void SUnionCmd::DoInitial() {
Expand Down Expand Up @@ -342,7 +340,6 @@ void SMoveCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->SMove(src_key_, dest_key_, member_, &res);
if (s.ok() || s.IsNotFound()) {
res_.AppendInteger(res);
AddSlotKey("s", src_key_, slot);
} else {
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
Expand Down

0 comments on commit 6f9f9ec

Please sign in to comment.