kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

fix integer paring error in listpack and ziplist when load RDB

Open w4096 opened this issue 2 years ago • 2 comments
trafficstars

When parsing listpack and ziplist when loading RDB, they don't correctly handle negetive integer. in This PR i try to fix this.

When I fix the problem, I think we can make the code more simpler, and I can't stop myself do those changes:

  • fix int parse bug in listpack and ziplist
  • reimplement the next method using a input string stream
  • remove unused public method of ZipList and ListPack (Length and Next). User can't call this method because it consume the input. Next and Length is used by Entries, we should make them private.

In InputStringStream I use execption rather than StatusOr. If using StatusOr, I must wrap every stream.Read call in GET_OR_RET, this make code hard to read.

By using InputStringStream you can easily handle offset, you can easily read certain bytes integer and string.

w4096 avatar Nov 08 '23 14:11 w4096

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 36 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Nov 08 '23 15:11 sonarqubecloud[bot]

Thanks for the bugfix

However, changing the style from Status to exception only in this submodule is so weird...

mapleFU avatar Nov 08 '23 15:11 mapleFU

Close PR due to lack of active, free feel to reopen if the issue is still living.

git-hulk avatar Mar 20 '24 08:03 git-hulk