Skip to content

Commit

Permalink
bugfix: fix vaild to valid
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiaoshuai123 committed Jul 30, 2024
1 parent 7e61a4f commit c81e681
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pikiwidb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Build
run: |
bash build.sh --verbose
bash build.sh
- name: GTest
working-directory: ${{ github.workspace }}/build-release
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void HIncrbyFloatCmd::DoCmd(PClient* client) {
} else if (s.IsInvalidArgument() &&
s.ToString().substr(0, std::char_traits<char>::length(ErrTypeMessage)) == ErrTypeMessage) {
client->SetRes(CmdRes::kMultiKey);
} else if (s.IsCorruption() && s.ToString() == "Corruption: value is not a vaild float") {
} else if (s.IsCorruption() && s.ToString() == "Corruption: value is not a valid float") {
client->SetRes(CmdRes::kInvalidFloat);
} else if (s.IsInvalidArgument()) {
client->SetRes(CmdRes::kOverFlow);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void IncrbyFloatCmd::DoCmd(PClient* client) {
if (s.ok()) {
client->AppendStringLen(ret.size());
client->AppendContent(ret);
} else if (s.IsCorruption() && s.ToString() == "Corruption: Value is not a vaild float") {
} else if (s.IsCorruption() && s.ToString() == "Corruption: Value is not a valid float") {
client->SetRes(CmdRes::kInvalidFloat);
} else if (s.IsInvalidArgument()) {
client->SetRes(CmdRes::KIncrByOverFlow);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool LSetCmd::DoInitial(PClient* client) {
}

void LSetCmd::DoCmd(PClient* client) {
// isVaildNumber ensures that the string is in decimal format,
// isValidNumber ensures that the string is in decimal format,
// while strtol ensures that the string is within the range of long type
const std::string index_str = client->argv_[2];

Expand Down
1 change: 1 addition & 0 deletions src/pstd/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "env.h"
#include "log.h"

#include <dirent.h>
#include <fcntl.h>
Expand Down
8 changes: 4 additions & 4 deletions src/storage/include/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ struct KeyInfo {
uint64_t keys = 0;
uint64_t expires = 0;
uint64_t avg_ttl = 0;
uint64_t invaild_keys = 0;
uint64_t invalid_keys = 0;

KeyInfo() : keys(0), expires(0), avg_ttl(0), invaild_keys(0) {}
KeyInfo() : keys(0), expires(0), avg_ttl(0), invalid_keys(0) {}

KeyInfo(uint64_t k, uint64_t e, uint64_t a, uint64_t i) : keys(k), expires(e), avg_ttl(a), invaild_keys(i) {}
KeyInfo(uint64_t k, uint64_t e, uint64_t a, uint64_t i) : keys(k), expires(e), avg_ttl(a), invalid_keys(i) {}

KeyInfo operator+(const KeyInfo& info) {
KeyInfo res;
res.keys = keys + info.keys;
res.expires = expires + info.expires;
res.avg_ttl = avg_ttl + info.avg_ttl;
res.invaild_keys = invaild_keys + info.invaild_keys;
res.invalid_keys = invalid_keys + info.invalid_keys;
return res;
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/storage/src/redis_hashes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Status Redis::ScanHashesKeyNum(KeyInfo* key_info) {
uint64_t keys = 0;
uint64_t expires = 0;
uint64_t ttl_sum = 0;
uint64_t invaild_keys = 0;
uint64_t invalid_keys = 0;

rocksdb::ReadOptions iterator_options;
const rocksdb::Snapshot* snapshot;
Expand All @@ -44,7 +44,7 @@ Status Redis::ScanHashesKeyNum(KeyInfo* key_info) {
}
ParsedHashesMetaValue parsed_hashes_meta_value(iter->value());
if (parsed_hashes_meta_value.IsStale() || parsed_hashes_meta_value.Count() == 0) {
invaild_keys++;
invalid_keys++;
} else {
keys++;
if (!parsed_hashes_meta_value.IsPermanentSurvival()) {
Expand All @@ -58,7 +58,7 @@ Status Redis::ScanHashesKeyNum(KeyInfo* key_info) {
key_info->keys = keys;
key_info->expires = expires;
key_info->avg_ttl = (expires != 0) ? ttl_sum / expires : 0;
key_info->invaild_keys = invaild_keys;
key_info->invalid_keys = invalid_keys;
return Status::OK();
}

Expand Down Expand Up @@ -345,7 +345,7 @@ Status Redis::HIncrbyfloat(const Slice& key, const Slice& field, const Slice& by
long double long_double_by;

if (StrToLongDouble(by.data(), by.size(), &long_double_by) == -1) {
return Status::Corruption("value is not a vaild float");
return Status::Corruption("value is not a valid float");
}

BaseMetaKey base_meta_key(key);
Expand Down Expand Up @@ -382,7 +382,7 @@ Status Redis::HIncrbyfloat(const Slice& key, const Slice& field, const Slice& by
ParsedBaseDataValue parsed_internal_value(&old_value_str);
parsed_internal_value.StripSuffix();
if (StrToLongDouble(old_value_str.data(), old_value_str.size(), &old_value) == -1) {
return Status::Corruption("value is not a vaild float");
return Status::Corruption("value is not a valid float");
}

total = old_value + long_double_by;
Expand Down
6 changes: 3 additions & 3 deletions src/storage/src/redis_lists.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Status Redis::ScanListsKeyNum(KeyInfo* key_info) {
uint64_t keys = 0;
uint64_t expires = 0;
uint64_t ttl_sum = 0;
uint64_t invaild_keys = 0;
uint64_t invalid_keys = 0;

rocksdb::ReadOptions iterator_options;
const rocksdb::Snapshot* snapshot;
Expand All @@ -38,7 +38,7 @@ Status Redis::ScanListsKeyNum(KeyInfo* key_info) {
}
ParsedListsMetaValue parsed_lists_meta_value(iter->value());
if (parsed_lists_meta_value.IsStale() || parsed_lists_meta_value.Count() == 0) {
invaild_keys++;
invalid_keys++;
} else {
keys++;
if (!parsed_lists_meta_value.IsPermanentSurvival()) {
Expand All @@ -52,7 +52,7 @@ Status Redis::ScanListsKeyNum(KeyInfo* key_info) {
key_info->keys = keys;
key_info->expires = expires;
key_info->avg_ttl = (expires != 0) ? ttl_sum / expires : 0;
key_info->invaild_keys = invaild_keys;
key_info->invalid_keys = invalid_keys;
return Status::OK();
}

Expand Down
42 changes: 21 additions & 21 deletions src/storage/src/redis_sets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rocksdb::Status Redis::ScanSetsKeyNum(KeyInfo* key_info) {
uint64_t keys = 0;
uint64_t expires = 0;
uint64_t ttl_sum = 0;
uint64_t invaild_keys = 0;
uint64_t invalid_keys = 0;

rocksdb::ReadOptions iterator_options;
const rocksdb::Snapshot* snapshot;
Expand All @@ -45,7 +45,7 @@ rocksdb::Status Redis::ScanSetsKeyNum(KeyInfo* key_info) {
}
ParsedSetsMetaValue parsed_sets_meta_value(iter->value());
if (parsed_sets_meta_value.IsStale() || parsed_sets_meta_value.Count() == 0) {
invaild_keys++;
invalid_keys++;
} else {
keys++;
if (!parsed_sets_meta_value.IsPermanentSurvival()) {
Expand All @@ -59,7 +59,7 @@ rocksdb::Status Redis::ScanSetsKeyNum(KeyInfo* key_info) {
key_info->keys = keys;
key_info->expires = expires;
key_info->avg_ttl = (expires != 0) ? ttl_sum / expires : 0;
key_info->invaild_keys = invaild_keys;
key_info->invalid_keys = invalid_keys;
return rocksdb::Status::OK();
}

Expand Down Expand Up @@ -186,7 +186,7 @@ rocksdb::Status Redis::SDiff(const std::vector<std::string>& keys, std::vector<s
uint64_t version = 0;
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (uint32_t idx = 1; idx < keys.size(); ++idx) {
Expand All @@ -201,7 +201,7 @@ rocksdb::Status Redis::SDiff(const std::vector<std::string>& keys, std::vector<s
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
valid_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
}
} else if (!s.IsNotFound()) {
return s;
Expand Down Expand Up @@ -231,7 +231,7 @@ rocksdb::Status Redis::SDiff(const std::vector<std::string>& keys, std::vector<s
Slice member = parsed_sets_member_key.member();

found = false;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, member);
s = db_->Get(read_options, handles_[kSetsDataCF], sets_member_key.Encode(), &member_value);
if (s.ok()) {
Expand Down Expand Up @@ -269,7 +269,7 @@ rocksdb::Status Redis::SDiffstore(const Slice& destination, const std::vector<st
ScopeRecordLock l(lock_mgr_, destination);
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (uint32_t idx = 1; idx < keys.size(); ++idx) {
Expand All @@ -284,7 +284,7 @@ rocksdb::Status Redis::SDiffstore(const Slice& destination, const std::vector<st
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
valid_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
}
} else if (!s.IsNotFound()) {
return s;
Expand Down Expand Up @@ -314,7 +314,7 @@ rocksdb::Status Redis::SDiffstore(const Slice& destination, const std::vector<st
Slice member = parsed_sets_member_key.member();

found = false;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, member);
s = db_->Get(read_options, handles_[kSetsDataCF], sets_member_key.Encode(), &member_value);
if (s.ok()) {
Expand Down Expand Up @@ -379,7 +379,7 @@ rocksdb::Status Redis::SInter(const std::vector<std::string>& keys, std::vector<
uint64_t version = 0;
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (uint32_t idx = 1; idx < keys.size(); ++idx) {
Expand All @@ -394,7 +394,7 @@ rocksdb::Status Redis::SInter(const std::vector<std::string>& keys, std::vector<
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
valid_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
}
} else if (s.IsNotFound()) {
return rocksdb::Status::OK();
Expand Down Expand Up @@ -426,7 +426,7 @@ rocksdb::Status Redis::SInter(const std::vector<std::string>& keys, std::vector<
Slice member = parsed_sets_member_key.member();

reliable = true;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, member);
s = db_->Get(read_options, handles_[kSetsDataCF], sets_member_key.Encode(), &member_value);
if (s.ok()) {
Expand Down Expand Up @@ -469,7 +469,7 @@ rocksdb::Status Redis::SInterstore(const Slice& destination, const std::vector<s
ScopeRecordLock l(lock_mgr_, destination);
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (uint32_t idx = 1; idx < keys.size(); ++idx) {
Expand All @@ -485,7 +485,7 @@ rocksdb::Status Redis::SInterstore(const Slice& destination, const std::vector<s
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
valid_sets.push_back({keys[idx], parsed_sets_meta_value.Version()});
}
} else if (s.IsNotFound()) {
have_invalid_sets = true;
Expand Down Expand Up @@ -520,7 +520,7 @@ rocksdb::Status Redis::SInterstore(const Slice& destination, const std::vector<s
Slice member = parsed_sets_member_key.member();

reliable = true;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, member);
s = db_->Get(read_options, handles_[kSetsDataCF], sets_member_key.Encode(), &member_value);
if (s.ok()) {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ rocksdb::Status Redis::SUnion(const std::vector<std::string>& keys, std::vector<
std::string meta_value;
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (const auto& key : keys) {
Expand All @@ -1044,7 +1044,7 @@ rocksdb::Status Redis::SUnion(const std::vector<std::string>& keys, std::vector<
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({key, parsed_sets_meta_value.Version()});
valid_sets.push_back({key, parsed_sets_meta_value.Version()});
}
} else if (!s.IsNotFound()) {
return s;
Expand All @@ -1053,7 +1053,7 @@ rocksdb::Status Redis::SUnion(const std::vector<std::string>& keys, std::vector<

Slice prefix;
std::map<std::string, bool> result_flag;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, Slice());
prefix = sets_member_key.EncodeSeekKey();
KeyStatisticsDurationGuard guard(this, DataType::kSets, key_version.key);
Expand Down Expand Up @@ -1087,7 +1087,7 @@ rocksdb::Status Redis::SUnionstore(const Slice& destination, const std::vector<s
ScopeRecordLock l(lock_mgr_, destination);
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
std::vector<KeyVersion> vaild_sets;
std::vector<KeyVersion> valid_sets;
rocksdb::Status s;

for (const auto& key : keys) {
Expand All @@ -1102,7 +1102,7 @@ rocksdb::Status Redis::SUnionstore(const Slice& destination, const std::vector<s
DataTypeStrings[static_cast<int>(GetMetaValueType(meta_value))]));
} else {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
vaild_sets.push_back({key, parsed_sets_meta_value.Version()});
valid_sets.push_back({key, parsed_sets_meta_value.Version()});
}
} else if (!s.IsNotFound()) {
return s;
Expand All @@ -1112,7 +1112,7 @@ rocksdb::Status Redis::SUnionstore(const Slice& destination, const std::vector<s
Slice prefix;
std::vector<std::string> members;
std::map<std::string, bool> result_flag;
for (const auto& key_version : vaild_sets) {
for (const auto& key_version : valid_sets) {
SetsMemberKey sets_member_key(key_version.key, key_version.version, Slice());
prefix = sets_member_key.EncodeSeekKey();
KeyStatisticsDurationGuard guard(this, DataType::kSets, key_version.key);
Expand Down
10 changes: 5 additions & 5 deletions src/storage/src/redis_strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Status Redis::ScanStringsKeyNum(KeyInfo* key_info) {
uint64_t keys = 0;
uint64_t expires = 0;
uint64_t ttl_sum = 0;
uint64_t invaild_keys = 0;
uint64_t invalid_keys = 0;

rocksdb::ReadOptions iterator_options;
const rocksdb::Snapshot* snapshot;
Expand All @@ -41,7 +41,7 @@ Status Redis::ScanStringsKeyNum(KeyInfo* key_info) {
}
ParsedStringsValue parsed_strings_value(iter->value());
if (parsed_strings_value.IsStale()) {
invaild_keys++;
invalid_keys++;
} else {
keys++;
if (!parsed_strings_value.IsPermanentSurvival()) {
Expand All @@ -55,7 +55,7 @@ Status Redis::ScanStringsKeyNum(KeyInfo* key_info) {
key_info->keys = keys;
key_info->expires = expires;
key_info->avg_ttl = (expires != 0) ? ttl_sum / expires : 0;
key_info->invaild_keys = invaild_keys;
key_info->invalid_keys = invalid_keys;
return Status::OK();
}

Expand Down Expand Up @@ -553,7 +553,7 @@ Status Redis::Incrbyfloat(const Slice& key, const Slice& value, std::string* ret
std::string new_value;
long double long_double_by;
if (StrToLongDouble(value.data(), value.size(), &long_double_by) == -1) {
return Status::Corruption("Value is not a vaild float");
return Status::Corruption("Value is not a valid float");
}

BaseKey base_key(key);
Expand All @@ -576,7 +576,7 @@ Status Redis::Incrbyfloat(const Slice& key, const Slice& value, std::string* ret
long double total;
long double old_number;
if (StrToLongDouble(old_user_value.data(), old_user_value.size(), &old_number) == -1) {
return Status::Corruption("Value is not a vaild float");
return Status::Corruption("Value is not a valid float");
}
total = old_number + long_double_by;
if (LongDoubleToStr(total, &new_value) == -1) {
Expand Down
Loading

0 comments on commit c81e681

Please sign in to comment.