Add variable size prefix for microbench/db_basic_bench.cc KeyGenerator class + improve documentation #13709
+43
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pr adds an unfinished feature in the
KeyGenerator
class atmicrobench/db_basic_bench.cc
, removing the hard-coded limit for the prefix size of the key generator and improves the documentation of the class.Previously, the key generator would accept an optional prefix and force a limit of 4 bytes if one was provided. The changes in this pr make it so that the constructor accepts a
size_t prefix_size = 4
as a parameter to represent the desired bytes for the keys prefix. An assert ensures that the size can represent the givensize_t prefix_num
.To support this new feature's addition, the
Encode
function was also changed to accept a size parameter for encoding a variable size key/prefix while preserving endianness.This change improves flexibility for key generation in benchmarks and tests.
As a next step, I plan to explore increasing the maximum number of keys (max_keys_) that can be generated, which is currently limited by an assert. Feedback on this approach or suggestions for future improvements are welcome!