Skip to content

Commit

Permalink
fix scan bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixficsol committed May 20, 2024
1 parent 528c6b8 commit 690865d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pika_slot_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ int SlotsMgrtTagOneCmd::KeyTypeCheck(const std::shared_ptr<DB>& db) {
}
return -1;
}
key_type = storage::DataTypeToTag(type);
key_type_ = storage::DataTypeToTag(type);
if (type == storage::DataType::kNones) {
LOG(WARNING) << "Migrate slot key: " << key_ << " not found";
res_.AppendInteger(0);
Expand Down
4 changes: 2 additions & 2 deletions src/storage/src/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ int64_t Storage::Scan(const DataType& dtype, int64_t cursor, const std::string&
Status s = LoadCursorStartKey(dtype, cursor, &key_type, &start_key);
if (!s.ok()) {
// If want to scan all the databases, we start with the strings database
key_type = dtype == DataType::kAll ? DataTypeTag[static_cast<int>(dtype)] : DataTypeTag[static_cast<int>(DataType::kStrings)];
key_type = dtype == DataType::kAll ? DataTypeTag[static_cast<int>(DataType::kStrings)] : DataTypeTag[static_cast<int>(dtype)];
start_key = prefix;
cursor = 0;
}
Expand All @@ -1242,7 +1242,7 @@ int64_t Storage::Scan(const DataType& dtype, int64_t cursor, const std::string&
LOG(WARNING) << "Invalid key_type: " << key_type;
return 0;
}
std::copy(pos, iter_end, std::back_inserter(types));
std::copy(pos, iter_end - 2, std::back_inserter(types));
} else {
types.push_back(DataTypeTag[static_cast<int>(dtype)]);
}
Expand Down
1 change: 0 additions & 1 deletion src/storage/src/strings_value_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class ParsedStringsValue : public ParsedInternalValue {
public:
// Use this constructor after rocksdb::DB::Get();
explicit ParsedStringsValue(std::string* internal_value_str) : ParsedInternalValue(internal_value_str) {
// TODO Why need this logic; Mixficsol
if (internal_value_str->size() >= kStringsValueMinLength) {
size_t offset = 0;
type_ = static_cast<DataType>(static_cast<uint8_t>((*internal_value_str)[0]));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/keys.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ start_server {tags {"keys"}} {
assert_equal {list_1 list_2} [r keys * list]
assert_equal {zset_1 zset_2} [r keys * zset]
assert_equal {set_1 set_2} [r keys * set]
assert_equal {hash_1 hash_2 kv_1 kv_2 list_1 list_2 set_1 set_2 zset_1 zset_2} [r keys *]
assert_equal {kv_1 kv_2 hash_1 hash_2 set_1 set_2 list_1 list_2 zset_1 zset_2} [r keys *]
assert_equal {kv_1 kv_2} [r keys * STRING]
assert_equal {hash_1 hash_2} [r keys * HASH]
assert_equal {list_1 list_2} [r keys * LIST]
Expand Down

0 comments on commit 690865d

Please sign in to comment.