-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
🛠️ Refactor suggestion: Fragile string-based parsing of byte sizes #1187
Comments
hey @de-sh i would like to work on this. Could you assign this to me . |
Hey a quick question . I checked up on the issue and i can approach this in 2 ways . One i can directly convert the fields that accept the size (as string) to u64 so it directly stores the size as numerical value , but in this case i would have to find the locations where the method merge_quired_stats are called and modify the inputs as u64 from string . The other approach is to let the Structs (IngestionStats , StorageStats ) accept the value of size as string but we will add 3 new fields for each 3 size ( size , lifetime_size , deleted_size ) and when calling the ( ::new ) method we will convert the string val to u64 and store in the 3 new fields , so while calcuation we can use the u64 fields. Which one would you prefer from above or is there another approach that i should look into ? |
The right way to do this is to hold numbers in memory and deserialize/serialize from where necessary as string "x Bytes". Refer previous work done here: |
Is the de-sh:query-param repository the correct one where I should focus my contributions? Also according to my understanding, the structs will continue to accept values as they currently do. However, I will introduce functions to store these values as u64 in memory for efficient computation. Additionally, I will modify the serde serializer to ensure that when the struct is converted to JSON the values are formatted as strings in the "X Bytes" format. Is this correct ?
|
No, we need to serialize and deserialize into integers that will only remain as such in-memory. Serializing and deserialization should happen as "X Bytes"
You can make the changes against main branch here |
It looks like someone else addressed and resolved this issue before I could push my changes. I will look into other issues. |
Splitting on
" Bytes"
and re-parsing is susceptible to format changes. A more robust approach is to store sizes as numeric fields within theQueriedStats
,IngestionStats
, andStorageStats
, then only format them when returning or displaying. This prevents runtime errors if the format changes and simplifies logic.Also applies to: 95-128, 130-136
Originally posted by @coderabbitai[bot] in #1150 (comment)
The text was updated successfully, but these errors were encountered: