Conversation
The default key generator is quite conservative, serializing the entire record and generating a SHA-256 hash from it. For large data records with many strings, this can be quite expensive. Using a custom key generator allows you to use knowledge of the particular data being inserted to generate a unique key using fewer resources.
This is safe as we don't story the key as is. If it is stored, it is first converted to a dataMapKey, which is a string type.
horgh
requested changes
Oct 4, 2023
data_key.go
Outdated
| // data. | ||
| // | ||
| // Please be certain that any key you generate is unique. If there is a | ||
| // collision with two different values having the same key, ones of the |
horgh
approved these changes
Oct 5, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A custom key generator can significantly improve the insertion performance
when you are able to use domain knowledge of the specific data being
inserted to more efficiently generate a unique key.
This also has some small performance improvements when using the default
key generator.