Skip to content
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

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Dec 6, 2024

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.

Copy link
Contributor Author

rphmeier commented Dec 6, 2024

@rphmeier rphmeier force-pushed the rh-THR-53-overflow-cell-value-hash branch from 86f7e9c to d1f20ec Compare December 6, 2024 17:50
Copy link
Contributor

@pepyakin pepyakin left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@pepyakin pepyakin merged commit f96da7c into master Dec 8, 2024
8 checks passed
@pepyakin pepyakin deleted the rh-THR-53-overflow-cell-value-hash branch December 8, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants