-
Notifications
You must be signed in to change notification settings - Fork 12
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(beatree)!: include value hash in overflow cells #602
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
86f7e9c
to
d1f20ec
Compare
d1f20ec
to
ed25760
Compare
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.
Gotcha: this changes the database format and as such should bump the DB version number.
@@ -41,7 +41,7 @@ pub const MAX_LEAF_VALUE_SIZE: usize = (LEAF_NODE_BODY_SIZE / 3) - 32; | |||
/// The maximum number of node pointers which may appear directly in an overflow cell. | |||
/// | |||
/// Note that this gives an overflow value cell maximum size of 100 bytes. | |||
pub const MAX_OVERFLOW_CELL_NODE_POINTERS: usize = 23; | |||
pub const MAX_OVERFLOW_CELL_NODE_POINTERS: usize = 15; |
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.
Does this require updating the comment above?
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.
No. 15*4 + 32 + 8 = 100 still.
|
||
/// Create an insertion, determining whether to use the normal or overflow variant based on size. | ||
pub fn insert<T: crate::ValueHasher>(v: Vec<u8>) -> Self { | ||
if v.len() > MAX_LEAF_VALUE_SIZE { |
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.
Tbf, not sure if this is a good place for such a decision.
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 wasn't sure either, but I would also prefer not to leak MAX_LEAF_VALUE_SIZE
anywhere else in the codebase. It should be part of the beatree
module, and ValueChange
is used everywhere within beatree/mod.rs
. This feels like the least-bad option. Do you have another suggestion?
Including the value hash in overflow cells enables us to always obtain the value hash associated with any key just by reading the relevant leaf. This is a pre-requisite for removing leaf-children.