Skip to content

Commit

Permalink
Supplements of guideline of compilation on macOS with make and clean …
Browse files Browse the repository at this point in the history
…up some code (apache#334)
  • Loading branch information
LykxSassinator authored and ShooterIT committed Sep 9, 2021
1 parent 2cdd69d commit a01c8f5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sudo yum install -y epel-release && sudo yum install -y git gcc gcc-c++ make sna
sudo apt-get install gcc g++ make libsnappy-dev autoconf automake libtool which libgtest-dev

# MACOSX
brew install snappy googletest
brew install autoconf automake libtool snappy googletest
```

It is as simple as:
Expand Down
2 changes: 1 addition & 1 deletion src/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ class CommandHMSet : public Commander {
Redis::Hash hash_db(svr->storage_, conn->GetNamespace());
std::vector<FieldValue> field_values;
for (unsigned int i = 2; i < args_.size(); i += 2) {
field_values.push_back(FieldValue{args_[i], args_[i + 1]});
field_values.emplace_back(FieldValue{args_[i], args_[i + 1]});
}
rocksdb::Status s = hash_db.MSet(args_[1], field_values, false, &ret);
if (!s.ok()) {
Expand Down
11 changes: 6 additions & 5 deletions src/redis_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ rocksdb::Status Database::FindKeyRangeWithPrefix(const std::string &prefix,
if (cf_handle == nullptr) {
cf_handle = metadata_cf_handle_;
}
if (prefix.empty()) {
return rocksdb::Status::NotFound();
}
begin->clear();
end->clear();

Expand All @@ -461,10 +464,8 @@ rocksdb::Status Database::FindKeyRangeWithPrefix(const std::string &prefix,
// it's ok to increase the last char in prefix as the boundary of the prefix
// while we limit the namespace last char shouldn't be larger than 128.
std::string next_prefix = prefix;
char last_char = next_prefix.back();
last_char++;
next_prefix.pop_back();
next_prefix.push_back(last_char);
auto prefix_size = prefix.size();
next_prefix[prefix_size - 1]++;
iter->SeekForPrev(next_prefix);
int max_prev_limit = 128; // prevent unpredicted long while loop
int i = 0;
Expand Down Expand Up @@ -553,7 +554,7 @@ std::string WriteBatchLogData::Encode() {
}

Status WriteBatchLogData::Decode(const rocksdb::Slice &blob) {
std::string log_data = blob.ToString();
const std::string& log_data = blob.ToString();
std::vector<std::string> args;
Util::Split(log_data, " ", &args);
type_ = static_cast<RedisType >(std::stoi(args[0]));
Expand Down
5 changes: 3 additions & 2 deletions src/redis_hash.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "redis_hash.h"
#include <utility>
#include <limits>
#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -168,14 +169,14 @@ rocksdb::Status Hash::MGet(const Slice &user_key,
rocksdb::Status Hash::Set(const Slice &user_key, const Slice &field, const Slice &value, int *ret) {
FieldValue fv = {field.ToString(), value.ToString()};
std::vector<FieldValue> fvs;
fvs.push_back(fv);
fvs.emplace_back(std::move(fv));
return MSet(user_key, fvs, false, ret);
}

rocksdb::Status Hash::SetNX(const Slice &user_key, const Slice &field, Slice value, int *ret) {
FieldValue fv = {field.ToString(), value.ToString()};
std::vector<FieldValue> fvs;
fvs.push_back(fv);
fvs.emplace_back(std::move(fv));
return MSet(user_key, fvs, true, ret);
}

Expand Down
1 change: 0 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ Status SockConnect(std::string host, uint32_t port, int *fd, uint64_t conn_timeo
return Status(Status::NotOK, strerror(errno));
}
SockSetTcpNoDelay(*fd, 1);
SockSetTcpNoDelay(*fd, 1);
}
if (timeout > 0) {
struct timeval tv;
Expand Down

0 comments on commit a01c8f5

Please sign in to comment.