-
Notifications
You must be signed in to change notification settings - Fork 263
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): deserialize one pojo into another type #2012
base: main
Are you sure you want to change the base?
Conversation
@@ -22,7 +22,7 @@ | |||
import org.apache.fury.type.TypeUtils; | |||
|
|||
public class ClassSpec { | |||
public final String entireClassName; | |||
public String entireClassName; |
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.
I prefer to keep ClassDef immutable abd return a new ClassDef instead
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.
Sure ofc, im still stuck facing exception here and there.
128b203
to
04a9e14
Compare
Hi @chaokunyang, need your help here. |
ClassInfo classInfo = readClassInfoWithMetaShare(buffer, fury.getSerializationContext().getMetaContext()); | ||
|
||
// replace target class if needed | ||
if (!targetClass.getName().equals(classInfo.getCls().getName())) { |
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 (!targetClass.getName().equals(classInfo.getCls().getName())) { | |
if (targetClass != classInfo.getCls()) { |
this will be much faster
ClassInfo targetClassInfo = getClassInfo(targetClass); | ||
buildClassDef(targetClassInfo); | ||
classInfo.classDef = ClassDef.replaceRootClassTo(this, targetClassInfo); | ||
classInfo.serializer = createSerializer(targetClass); |
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 line won't work as you expect. It just create a serializer for raw targetClass
without using type info from peer class
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.
Ok I'll look into that first
@orisgarno I make it work in 52dfea2 , you can continue the work now. And it seems the tests you write have some issues, please take a look at it. |
Hi @orisgarno , could you also update the user guide document about how to deserialize one type into another? |
What does this PR do?
replace class def if target class is different type with the actual serialized one, so it can be deserialized to another type
#1998
Related issues
Does this PR introduce any user-facing change?
Benchmark