Open DemonJun opened 11 months ago
One of the solution is adding a copy interface to io.fury.Serializer
:
public T copy(T value) {
throw new UnsupportedOperationException(String.format("Copy for %s is not supported", value.getClass()));
}
For immutable types such as String/java.time.*
, this implementation just return the passed object. For mutable object such as ArrayList/HashMap/POJO
, we copy the data recursive in copy
implementation.
I want to try it,but I may need a little time to learn this
I want to try it,but I may need a little time to learn this
Looking forward to it! FYI, here are my some thoughts, you can take it for inspiration:
Serializer
implement the copy interface, throw UnsupportedExceptionString
, java.time
, just return itselfObjectSerializer/CompatibleObjectSerializer
io.fury.builder.Generated.GeneratedSerializer
:
public Object copy(Object o) {
Copy copier = this.copier;
if (copier == null) {
this.copier = copier = classResolver.getJITCopier(o.getClass());
}
return copier.copy(o);
}
During data stream processing, it is often necessary to deep copy data for multiple times, especially when there are too many class attributes and subclasses, manual deep copying is too much trouble. Similarly:
It would be nice to be able to use zero-copy to further improve performance.