feat: Add support for high resolution fractional#1740
feat: Add support for high resolution fractional#1740chrfwow wants to merge 24 commits intoopen-feature:mainfrom
Conversation
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| ] | ||
| ], | ||
| "result": "blue" | ||
| "result": "red" |
There was a problem hiding this comment.
In some cases, we will compute a different bucket now
|
Do we want more tests for this? I stuck to the current test suite |
There was a problem hiding this comment.
Code Review
The pull request refactors the fractional targeting logic to support various input types (numbers, booleans) for bucketing by converting them to byte arrays and introduces a new numberToByteArray helper. The core bucketing algorithm was also revised to use an integer-based bit shift operation. Review comments highlight two key areas for improvement: the numberToByteArray method has a potential precision loss issue for BigDecimal and could be made more concise using ByteBuffer, and the bucketing logic has a subtle bug related to handling signed vs. unsigned integers from the MurmurHash3 function, which requires a bitmask for correct range mapping.
.../flagd-core/src/main/java/dev/openfeature/contrib/tools/flagd/core/targeting/Fractional.java
Outdated
Show resolved
Hide resolved
| long mmrHash = MurmurHash3.hash32x86(hashKey, 0, hashKey.length, 0); | ||
| int bucket = (int) (((mmrHash * totalWeight) >> 32) & 0xFFFFFFFFL); |
There was a problem hiding this comment.
The bucketing logic has a subtle issue with signed vs. unsigned integers. MurmurHash3.hash32x86 returns a signed int. To correctly use it for range mapping as an unsigned 32-bit value, it should be converted to a long using a bitmask to avoid sign extension. This ensures the bucketing is fair and consistent across different hash values.
long mmrHash = MurmurHash3.hash32x86(hashKey, 0, hashKey.length, 0) & 0xFFFFFFFFL;
int bucket = (int) ((mmrHash * totalWeight) >> 32);Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
|
Idk why there are PMD errors, but I think they are unrelated and false positives |
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
| Integer.MIN_VALUE, | ||
| Integer.MIN_VALUE + 1 | ||
| }) | ||
| void edgeCasesDoNotThrow(int hash) throws JsonLogicException { |
There was a problem hiding this comment.
This only tests that we will find a bucket for edge case inputs, but it will not validate the correctness
There was a problem hiding this comment.
removed, validated through the gherkin suite
| } | ||
|
|
||
| @Test | ||
| void statistics() throws JsonLogicException { |
There was a problem hiding this comment.
This tests the statistical distribution. The test takes 340ms on my machine, I think we can live with it, but I can also delete or disable it if we want to
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
# Conflicts: # providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunInProcessTest.java
| "type": "object", | ||
| "properties": { | ||
| "flags": { | ||
| "$ref": "#/definitions/providerConfig", |
There was a problem hiding this comment.
I don't understand why there are changes in this file. They seem to be auto-generated when running the flagd-core test target
There was a problem hiding this comment.
could be that those are copied from the flagd-schema repo
There was a problem hiding this comment.
Ya I think that's what it is - I believe it's coming from there.
I think maybe we should gitignore it?
There was a problem hiding this comment.
it already is gitignored 🤔
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
|
Waiting for open-feature/flagd-testbed#340 |
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
.../flagd-core/src/main/java/dev/openfeature/contrib/tools/flagd/core/targeting/Fractional.java
Outdated
Show resolved
Hide resolved
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
|
@chrfwow there was some e2e test failures but I fixed them by updating to the latest git submodule in the testkit module, and adding the v1 exclusion to the file mode suite, and excluding v2 in the RPC suite (since flagd doesn't support this yet). I will coordinate the release of flagd, then update the RPC suite here and release everything simultaneously. |
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
This PR
Adds high resolution fractional support
Related Issues
Fixes #1738