-
Notifications
You must be signed in to change notification settings - Fork 246
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
feat(java): Add EnumNameSerializer for Enum #1791
feat(java): Add EnumNameSerializer for Enum #1791
Conversation
java/fury-core/src/main/java/org/apache/fury/config/FuryBuilder.java
Outdated
Show resolved
Hide resolved
java/fury-core/src/main/java/org/apache/fury/config/Config.java
Outdated
Show resolved
Hide resolved
java/fury-core/src/main/java/org/apache/fury/resolver/EnumStringResolver.java
Outdated
Show resolved
Hide resolved
java/fury-core/src/main/java/org/apache/fury/serializer/EnumNameSerializer.java
Outdated
Show resolved
Hide resolved
java/fury-core/src/main/java/org/apache/fury/serializer/EnumNameSerializer.java
Outdated
Show resolved
Hide resolved
Hi @xxd819240366 , thanks for contribuing to Apache Fury. The code looks to me overall, I left some minor comments. And would you like to update |
Ok,I'll update it again |
…e/fury into 0.7.1_add_enum_name_serializer
By the way, I can pass all test on my local development environment with java 8,but can't pass test on Java CI(8) . There is a error in org.apache.fury.serializer.EnumSerializerTest.testEnumSubclassFieldCompatible(org.apache.fury.serializer.EnumSerializerTest) only happen on github CI pipline |
Seems some your jar version is 0.7.0 but others are 0.8.0-SNAPSHOT. Could you update all mavem module to 0.8.0-SNAPSHOT? |
@chaokunyang Seems all maven module version already updated to 0.8.0-SNAPSHOT |
public Enum read(MemoryBuffer buffer) { | ||
MetaStringBytes metaStringBytes = metaStringResolver.readMetaStringBytes(buffer); | ||
if (!enumMap.containsKey(metaStringBytes)) { | ||
Optional<NonexistentEnum> first = enumMap.values().stream().findFirst(); |
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.
if deserializeNonexistentEnumValueAsNull
is enabled, we should return null here, otherwise we should throw Exception
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.
Or instead of returning null, we could return NonexistentEnum.UNKNOWN
instead
Optional<NonexistentEnum> first = enumMap.values().stream().findFirst(); | ||
return first.orElse(null); | ||
} | ||
return enumMap.get(metaStringBytes); |
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.
This introduce a second map loopkup, we should avoid it. we can value = enumMap.get(xxx);
and check whether value
is null instead of check by containsKey
@lionel-xie Could you merge fury main branch first, your base branch is 0.7.0, not the developer main branch |
done in #1892 |
What does this PR do?
Add EnumNameSerializer for Enum, can config it by org.apache.fury.config.Config#useEnumNameSerializer, default value is false
Related issues
Does this PR introduce any user-facing change?
Benchmark