Skip to content

Commit

Permalink
fixed minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep committed Jul 25, 2018
1 parent 2f92be5 commit 6f8f278
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pika_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void HGetallCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info)
void HGetallCmd::Do() {
std::vector<blackwidow::FieldValue> fvs;
rocksdb::Status s = g_pika_server->bdb()->HGetall(key_, &fvs);
if (s.ok()) {
if (s.ok() || s.IsNotFound()) {
res_.AppendArrayLen(fvs.size() * 2);
for (const auto& fv : fvs) {
res_.AppendStringLen(fv.field.size());
Expand Down
6 changes: 3 additions & 3 deletions src/pika_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void SetCmd::Do() {
int32_t res = 1;
switch (condition_) {
case SetCmd::kXX:
s = g_pika_server->bdb()->Setxx(key_, value_, &res);
s = g_pika_server->bdb()->Setxx(key_, value_, &res, sec_);
break;
case SetCmd::kNX:
s = g_pika_server->bdb()->Setnx(key_, value_, &res);
s = g_pika_server->bdb()->Setnx(key_, value_, &res, sec_);
break;
default:
s = g_pika_server->bdb()->Set(key_, value_);
s = g_pika_server->bdb()->Set(key_, value_, sec_);
break;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pika_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void SRandmemberCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_i
void SRandmemberCmd::Do() {
std::vector<std::string> members;
rocksdb::Status s = g_pika_server->bdb()->SRandmember(key_, count_, &members);
if (s.ok() || s.IsNotFound()) {
if (s.ok()) {
if (!reply_arr && members.size()) {
res_.AppendStringLen(members[0].size());
res_.AppendContent(members[0]);
Expand All @@ -389,6 +389,8 @@ void SRandmemberCmd::Do() {
res_.AppendContent(member);
}
}
} else if (s.IsNotFound()) {
res_.AppendStringLen(-1);
} else {
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
Expand Down
14 changes: 11 additions & 3 deletions src/pika_zset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void ZRangeCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info)
void ZRangeCmd::Do() {
std::vector<blackwidow::ScoreMember> score_members;
rocksdb::Status s = g_pika_server->bdb()->ZRange(key_, start_, stop_, &score_members);
if (s.ok()) {
if (s.ok() || s.IsNotFound()) {
if (is_ws_) {
char buf[32];
int64_t len;
Expand Down Expand Up @@ -367,6 +367,15 @@ void ZRevrangebyscoreCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const
return;
}
ZsetRangebyscoreParentCmd::DoInitial(argv, NULL);
double tmp_score;
tmp_score = min_score_;
min_score_ = max_score_;
max_score_ = tmp_score;

bool tmp_close;
tmp_close = left_close_;
left_close_ = right_close_;
right_close_ = tmp_close;
}

void ZRevrangebyscoreCmd::Do() {
Expand Down Expand Up @@ -780,13 +789,12 @@ void ZLexcountCmd::Do() {
return;
}
int32_t count = 0;
std::vector<std::string> members;
rocksdb::Status s = g_pika_server->bdb()->ZLexcount(key_, min_member_, max_member_, left_close_, right_close_, &count);
if (!s.ok() && !s.IsNotFound()) {
res_.SetRes(CmdRes::kErrOther, s.ToString());
return;
}
res_.AppendInteger(members.size());
res_.AppendInteger(count);
return;
}

Expand Down

0 comments on commit 6f8f278

Please sign in to comment.