Skip to content

feat(rdb): add DUMP support for SortedInt type#3366

Merged
git-hulk merged 3 commits intoapache:unstablefrom
Zakir032002:feature/sortedint-dump-support
Feb 10, 2026
Merged

feat(rdb): add DUMP support for SortedInt type#3366
git-hulk merged 3 commits intoapache:unstablefrom
Zakir032002:feature/sortedint-dump-support

Conversation

@Zakir032002
Copy link
Contributor

  • Serialize SortedInt as RDB Set for Redis compatibility
  • Use RangeByValue() to get all integers deterministically
  • No RESTORE changes (SortedInt dumps restore as Set, like Bitmap→String)
  • Resolves part of Add support of the DUMP with all data types #3319

Testing:

  • Manual test confirms DUMP no longer returns error
  • RESTORE successfully creates Set with preserved data
  • All integers maintained in restored Set

Manuel test:
root@codespaces-6e5713:/workspaces/kvrocks# # Connect to Kvrocks
redis-cli -p 6666

127.0.0.1:6666> SIADD testkey 100 200 300
(integer) 0 // already exists

127.0.0.1:6666> SICARD testkey
(integer) 3

127.0.0.1:6666> TYPE testkey
sortedint

127.0.0.1:6666> DUMP testkey
"\x02\x03\xc0d\xc1\xc8\x00\xc1,\x01\x06\x00\xb2\x01\xaa\xe2\x06h\xba\x8d"

127.0.0.1:6666> SIADD mykey 5 12 23 89 100
(integer) 0
127.0.0.1:6666> DUMP mykey
"\x02\x05\xc0\x05\xc0\x0c\xc0\x17\xc0Y\xc0d\x06\x00\xa8\x19U\x90\x8f\x011o"

127.0.0.1:6666> RESTORE newkey 0 "\x02\x05\xc0\x05\xc0\x0c\xc0\x17\xc0Y\xc0d\x06\x00\xa8\x19U\x90\x8f\x011o"
OK

127.0.0.1:6666> TYPE newkey
set

127.0.0.1:6666> SMEMBERS newkey

  1. "100"
  2. "12"
  3. "23"
  4. "5"
  5. "89"
    127.0.0.1:6666> DUMP nonexistent
    (nil)
    127.0.0.1:6666> exit

- Serialize SortedInt as RDB Set for Redis compatibility
- Use RangeByValue() to get all integers deterministically
- No RESTORE changes (SortedInt dumps restore as Set, like Bitmap→String)
- Resolves part of apache#3319

Testing:
- Manual test confirms DUMP no longer returns error
- RESTORE successfully creates Set with preserved data
- All integers maintained in restored Set
@Zakir032002 Zakir032002 marked this pull request as ready for review February 7, 2026 12:15
Zakir032002 added a commit to Zakir032002/kvrocks that referenced this pull request Feb 7, 2026
- Implement custom RDB type 22 for SortedInt
- Add SaveSortedintObject() and LoadSortedintObject()
- Preserve SortedInt type in DUMP/RESTORE cycle
- Update RedisObjValue variant to support vector<uint64_t>
- All SortedInt commands work after RESTORE

This provides full type preservation as an alternative to the
coercion approach in PR apache#3366.

Closes apache#3319
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zakir032002 Could you please add Go test cases?

@Zakir032002
Copy link
Contributor Author

@git-hulk thank you for review, i have implemented this type in 2 approaches, can you finalise the approach that is preferred for this repo. Here is the another approach #3367 in the pull requests. After that i will add the go test cases according to it

Co-authored-by: hulk <hulk.website@gmail.com>
@Zakir032002
Copy link
Contributor Author

now added go test cases and fixed the code

@git-hulk git-hulk changed the title feat: Add DUMP support for SortedInt type feat(rdb): add DUMP support for SortedInt type Feb 10, 2026
@git-hulk git-hulk enabled auto-merge (squash) February 10, 2026 13:08
@git-hulk git-hulk merged commit a10b6e1 into apache:unstable Feb 10, 2026
71 of 74 checks passed
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants