-
Notifications
You must be signed in to change notification settings - Fork 281
fix(java): Use (long, long, byte) key for MetaStringBytes cache to prevent collisions #2308
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
Merged
Conversation
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
- Rename `pythonMudule` to `pythonModule` in lib/util/cross_lang_util.dart - Update test case and group titles in test/ to match the Dart test package example format
# Conflicts: # dart/packages/fury-test/lib/util/cross_lang_util.dart
chaokunyang
approved these changes
Jun 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
chaokunyang
pushed a commit
to chaokunyang/fury
that referenced
this pull request
Jun 7, 2025
…event collisions (apache#2308) ## What does this PR do? This PR fixes a `ClassCastException` during deserialization caused by an incorrect `MetaStringBytes` being retrieved from the cache. The previous cache key `(long, long)` in `MetaStringResolver` (for small meta strings) didn't include the string's `encoding` byte, leading to collisions when different strings (e.g., "aclass" vs "Aclass") hashed to the same two longs. **Changes:** 1. **Introduced `LongLongByteMap`:** A new map using a `(long k1, long k2, byte k3)` key. 2. **Updated `MetaStringResolver`:** Modified relevant methods (e.g., `createSmallMetaStringBytes`, `readSmallMetaStringBytes`) to use `LongLongByteMap`, incorporating the `encoding` byte into the cache key for small meta strings. 3. **Renamed Test:** `LongLongMapTest.java` renamed to `LongLongByteMapTest.java` and updated to test the new map. ## Related issues - apache#2307 ## Does this PR introduce any user-facing change? <!-- If any user-facing interface changes, please [open an issue](https://github.com/apache/fory/issues/new/choose) describing the need to do so and update the document if necessary. --> - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark <!-- When the PR has an impact on performance (if you don't know whether the PR will have an impact on performance, you can submit the PR first, and if it will have impact on performance, the code reviewer will explain it), be sure to attach a benchmark data here. -->
chaokunyang
pushed a commit
that referenced
this pull request
Jun 7, 2025
…event collisions (#2308) ## What does this PR do? This PR fixes a `ClassCastException` during deserialization caused by an incorrect `MetaStringBytes` being retrieved from the cache. The previous cache key `(long, long)` in `MetaStringResolver` (for small meta strings) didn't include the string's `encoding` byte, leading to collisions when different strings (e.g., "aclass" vs "Aclass") hashed to the same two longs. **Changes:** 1. **Introduced `LongLongByteMap`:** A new map using a `(long k1, long k2, byte k3)` key. 2. **Updated `MetaStringResolver`:** Modified relevant methods (e.g., `createSmallMetaStringBytes`, `readSmallMetaStringBytes`) to use `LongLongByteMap`, incorporating the `encoding` byte into the cache key for small meta strings. 3. **Renamed Test:** `LongLongMapTest.java` renamed to `LongLongByteMapTest.java` and updated to test the new map. ## Related issues - #2307 ## Does this PR introduce any user-facing change? <!-- If any user-facing interface changes, please [open an issue](https://github.com/apache/fory/issues/new/choose) describing the need to do so and update the document if necessary. --> - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark <!-- When the PR has an impact on performance (if you don't know whether the PR will have an impact on performance, you can submit the PR first, and if it will have impact on performance, the code reviewer will explain it), be sure to attach a benchmark data here. -->
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.
What does this PR do?
This PR fixes a
ClassCastException
during deserialization caused by an incorrectMetaStringBytes
being retrieved from the cache. The previous cache key(long, long)
inMetaStringResolver
(for small meta strings) didn't include the string'sencoding
byte, leading to collisions when different strings (e.g., "aclass" vs "Aclass") hashed to the same two longs.Changes:
LongLongByteMap
: A new map using a(long k1, long k2, byte k3)
key.MetaStringResolver
: Modified relevant methods (e.g.,createSmallMetaStringBytes
,readSmallMetaStringBytes
) to useLongLongByteMap
, incorporating theencoding
byte into the cache key for small meta strings.LongLongMapTest.java
renamed toLongLongByteMapTest.java
and updated to test the new map.Related issues
Does this PR introduce any user-facing change?
Benchmark