Commit a10b6e1
feat(rdb): add DUMP support for SortedInt type (#3366)
- 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 #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
---------
Co-authored-by: hulk <hulk.website@gmail.com>1 parent 11fa20b commit a10b6e1
File tree
3 files changed
+66
-0
lines changed- src/storage/rdb
- tests/gocase/unit/dump
3 files changed
+66
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
730 | 733 | | |
731 | 734 | | |
732 | 735 | | |
| 736 | + | |
| 737 | + | |
733 | 738 | | |
734 | 739 | | |
735 | 740 | | |
| |||
793 | 798 | | |
794 | 799 | | |
795 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
796 | 818 | | |
797 | 819 | | |
798 | 820 | | |
| |||
930 | 952 | | |
931 | 953 | | |
932 | 954 | | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
933 | 969 | | |
934 | 970 | | |
935 | 971 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
0 commit comments