Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Revert "fix version compare error in ZSetsScoreKeyComparatorImpl" #2583

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/storage/src/custom_comparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,15 @@ class ZSetsScoreKeyComparatorImpl : public rocksdb::Comparator {
auto b_size = static_cast<int32_t>(b.size());
int32_t key_a_len = DecodeFixed32(ptr_a);
int32_t key_b_len = DecodeFixed32(ptr_b);
rocksdb::Slice key_a_prefix(ptr_a, key_a_len + sizeof(int32_t));
rocksdb::Slice key_b_prefix(ptr_b, key_b_len + sizeof(int32_t));
ptr_a += key_a_len + sizeof(int32_t);
ptr_b += key_b_len + sizeof(int32_t);
rocksdb::Slice key_a_prefix(ptr_a, key_a_len + 2 * sizeof(int32_t));
rocksdb::Slice key_b_prefix(ptr_b, key_b_len + 2 * sizeof(int32_t));
ptr_a += key_a_len + 2 * sizeof(int32_t);
ptr_b += key_b_len + 2 * sizeof(int32_t);
int ret = key_a_prefix.compare(key_b_prefix);
if (ret) {
return ret;
}

int32_t version_a = DecodeFixed32(ptr_a);
int32_t version_b = DecodeFixed32(ptr_b);
if (version_a != version_b) {
return version_a < version_b ? -1 : 1;
}
ptr_a += sizeof(int32_t);
ptr_b += sizeof(int32_t);

uint64_t a_i = DecodeFixed64(ptr_a);
uint64_t b_i = DecodeFixed64(ptr_b);
const void* ptr_a_score = reinterpret_cast<const void*>(&a_i);
Expand Down
7 changes: 0 additions & 7 deletions src/storage/tests/custom_comparator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ TEST(ZSetScoreKeyComparator, FindShortestSeparatorTest) {
// printf("**********************************************************************\n");
ASSERT_TRUE(impl.Compare(change_start_9, start_9) >= 0);
ASSERT_TRUE(impl.Compare(change_start_9, limit_9) < 0);

// ***************** Group 10 Test *****************
ZSetsScoreKey zsets_score_key_start_10("Axlgrep", 1557212502, 3.1415, "abc");
ZSetsScoreKey zsets_score_key_limit_10("Axlgrep", 1557212752, 3.1415, "abc");
std::string start_10 = zsets_score_key_start_10.Encode().ToString();
std::string limit_10 = zsets_score_key_limit_10.Encode().ToString();
ASSERT_TRUE(impl.Compare(start_10, limit_10) < 0);
}

int main(int argc, char** argv) {
Expand Down
Loading