zhaommmmomo opened a new pull request, #1701: URL: https://github.com/apache/fury/pull/1701
## What does this PR do? Object deep copy framework in fury java. This PR is only for non-jit serializer - For immutable object such as `String`、`java.time`、`int`、`byte`... return itself. - For mutable object, create new object and set all attributes. - For `pojo` / `bean` object, Use `ObjectSerializer.copy(obj)` to create a new object - For `Arrays`、`Collection`、`Map` object, create new object, traverse the elements, call `fory.copy(obj)` to generate new elements and set them to the new object. Some serializers have special `copy` methods. ## Related issues [[Java] fast object copy framework in fury java #1679](https://github.com/apache/fury/issues/1679) ## Does this PR introduce any user-facing change? - [x] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? 1. Provide `fury.copy(obj)` interface, which can deep copy the object without serialize / deserialize. For example: ```java User user = new User(); user.setName("a"); // note: jit-serializer currently does not support copy capability. // If you need to use ObjectSerializer.copy() capability, you need to set withCodegen(false) // If object contain circular references, please enable copy ref tracking by FuryBuilder#withCopyRefTracking(true) Fury fury = Fury.builder().withLanguage(Language.JAVA).withCopyRefTracking(true).withCodegen(false).build(); User newUser = fury.copy(user); ``` 2. Provide `FuryCopyable<T>` interface, which can customize the copy method of object. For example: ```java public class User implements Serializable, FuryCopyable<User> { @Override public User copy(Fury fury) { // do something System.out.println("object custom copy method"); return newUser; } } ``` ## Benchmark -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
