Skip to content

Commit

Permalink
Revert "fix version compare error in ZSetsScoreKeyComparatorImpl (Ope…
Browse files Browse the repository at this point in the history
…nAtomFoundation#2339)"

This reverts commit e787eff.
  • Loading branch information
wangshaoyi authored and wangshao1 committed Apr 8, 2024
1 parent d7c92a7 commit fd0ef49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
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

0 comments on commit fd0ef49

Please sign in to comment.