-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New API for clean handling of VariantLengthKey (#282)
In this diff, we propose the new API for clean handling of VariantLengthKey. Previously, handling VariantLengthKey is extremely tricky and fragile (if possible at all), and requires writing code that any project with reasonable code quality standards would not tolerate. This is even causing bugs in our own codebase (e.g. Compaction contexts, and even the test that tests VariantLengthKey is buggy itself). We propose a backward-compatible new API to handle VariantLengthKey cleanly. We add a new concept -- ShallowKey. This class is required to provide the same APIs as the Key class (size(), GetHash() and operator==()), but unlike Key class, which raw contents (interpreted as a uint8_t* string) is directly written into the log, ShallowKey's internal representation does not matter. In addition to the existing APIs, a new API with prototype void write_deep_key_at(Key* dst) const is required, which should write the bytestream-representation of the Key into address 'dst'. In order to use the new API, all you need to do is to change the key() API in Context to return ShallowKey type, instead of key_t type. Example: struct UpsertContext { using key_t = Key; // uncomment below to use new API // ShallowKey key(); // uncomment below to use old API // key_t key(); };
- Loading branch information
1 parent
46de893
commit 88d7282
Showing
7 changed files
with
266 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.