-
Notifications
You must be signed in to change notification settings - Fork 9
fix: move confMergeSchedule next to confMergePolicy #708
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
Conversation
| (cfs :: MergeSchedule)) | ||
| = TableConfig cmp csz cwba cbfa cfit dcp cfs | ||
| override confDiskCachePolicy' TableConfig {..} | ||
| = TableConfig {confDiskCachePolicy = confDiskCachePolicy', ..} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes with a risk of forgetting to override all relevant places when new fields are added. Not super likely that the policy occurs more than once in the config, but maybe still a good habit to a be more explicit about these things. For previous discussion and an alternative approach that is not quite as verbose: #641 (comment))
| confMergePolicy <- decodeVersioned v | ||
| confSizeRatio <- decodeVersioned v | ||
| confWriteBufferAlloc <- decodeVersioned v | ||
| confBloomFilterAlloc <- decodeVersioned v | ||
| confFencePointerIndex <- decodeVersioned v | ||
| confDiskCachePolicy <- decodeVersioned v | ||
| confMergeSchedule <- decodeVersioned v | ||
| pure TableConfig {..} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be okay to make a change to the serialisation format now, before the library gets released.
But I kind of like that you make the order explicit here, instead of it implicitly being defined in the datatype declaration (which had a risk of changing it without being aware of the consequences).
| encode TableConfig {..} = | ||
| encodeListLen 7 | ||
| <> encode mergePolicy | ||
| <> encode sizeRatio | ||
| <> encode writeBufferAlloc | ||
| <> encode bloomFilterAlloc | ||
| <> encode fencePointerIndex | ||
| <> encode diskCachePolicy | ||
| <> encode mergeSchedule | ||
| where | ||
| TableConfig | ||
| mergePolicy | ||
| sizeRatio | ||
| writeBufferAlloc | ||
| bloomFilterAlloc | ||
| fencePointerIndex | ||
| diskCachePolicy | ||
| mergeSchedule | ||
| = config | ||
| <> encode confMergePolicy | ||
| <> encode confSizeRatio | ||
| <> encode confWriteBufferAlloc | ||
| <> encode confBloomFilterAlloc | ||
| <> encode confFencePointerIndex | ||
| <> encode confDiskCachePolicy | ||
| <> encode confMergeSchedule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The risk here is that one might forget to encode a new field. However, the decodeVersioned implementation would fail to compile, hopefully making it clear that encode also needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point here is that if you forget to encode a new field, the decode test fails, which hopefully lets you know that you messed up the encode function. Moreover, these functions are much less brittle depending on the order in the datatype. I've elaborated the pattern match to be explicit about names and total, which is much more verbose, but combines the best of both.
ee3fdf3 to
0c41a34
Compare
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, but this seems good to go either way.
| confWriteBufferAlloc = confWriteBufferAlloc, | ||
| confBloomFilterAlloc = confBloomFilterAlloc, | ||
| confFencePointerIndex = confFencePointerIndex, | ||
| confDiskCachePolicy = confDiskCachePolicy' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changed and unchanged lines seem super similar, which makes it a bit hard to see where the update happens. Two ideas for making the updated field stands out more:
- use a different name for the policy argument
- use
NamedFieldPunsin the other lines, so they're justconfMergePolicy,etc., making it super clear that the field is untouched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the NamedFieldPuns suggestion.
375cb74 to
0ce2354
Compare
0ce2354 to
75d28a7
Compare
This PR reorders the fields in
TableConfigto ensure that theMergePolicyandMergeScheduleare adjacent.