-
Notifications
You must be signed in to change notification settings - Fork 42
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
add secondary key dictionaries #303
Merged
hendrikmuhs
merged 24 commits into
KeyviDev:master
from
hendrikmuhs:secondary_key_playground
Jul 23, 2024
Merged
add secondary key dictionaries #303
hendrikmuhs
merged 24 commits into
KeyviDev:master
from
hendrikmuhs:secondary_key_playground
Jul 23, 2024
Conversation
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
hendrikmuhs
force-pushed
the
secondary_key_playground
branch
from
June 3, 2024 18:49
e7e6d50
to
fce56e4
Compare
hendrikmuhs
changed the title
playground for secondary key dictionaries
add secondary key dictionaries
Jun 17, 2024
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.
Secondary key dictionaries match a set of key before the real matching. Those secondary keys can be arbitrary strings, e.g. a user, account or a tenant id.
At compile time, a list of secondary keys must be provided at construction, e.g.
["region", "account_id", "user_id"]
. The order defines matching order. For every entry as well as for every match operation an unordered map of keys and values must be provided :Example use:
dictionary.complete("sie", {"account_id": "xyz", "region": "eu-west", "user_id": "abcd" })
With other words: APIs are equal to ordinary dictionaries with the extension of a map with secondary keys next to the primary key.
Implementation details
Before doing the real matching, the root state is altered according to the additional secondary key(s) by matching a prefix. Given the "moved" start state, re-use the existing match functionality from
Dictionary
. This is implemented by wrapping an ordinary dictionary (most code changes are just refactorings to provide the altered start state).The
SecondaryKeyDictionaryCompiler
is similar, it wraps the existingDictionaryCompiler
. In addition it:To efficiently store secondary key values, values get replaced by a short representation. This helps e.g. for cases where secondary key values are long, e.g. UUIDs. Equally to the primary dictionary the replacement dict uses memory mapping.
Python bindings
Unfortunately the python bindings required a lot of boiler plate code. In theory it could be auto-generated, however I wonder how much effort we should put into the autowrap generated code. I am playing with the idea to migrate to pybind11.