chaokunyang commented on issue #1958: URL: https://github.com/apache/fury/issues/1958#issuecomment-2501365172
@a1342772 Fury supports zero-copy serialization of primitive array, there is no cost for serializing such objects, and of course no compression, the serialized size of array will be `n_elements * size_of(element_type)`. You could use zero-copy serialization by https://fury.apache.org/docs/guide/java_object_graph_guide#zero-copy-serialization: ```java import org.apache.fury.*; import org.apache.fury.config.*; import org.apache.fury.serializer.BufferObject; import org.apache.fury.memory.MemoryBuffer; import java.util.*; import java.util.stream.Collectors; public class ZeroCopyExample { // Note that fury instance should be reused instead of creation every time. static Fury fury = Fury.builder() .withLanguage(Language.JAVA) .build(); // mvn exec:java -Dexec.mainClass="io.ray.fury.examples.ZeroCopyExample" public static void main(String[] args) { List<Object> list = Arrays.asList("str", new byte[1000], new int[100], new double[100]); Collection<BufferObject> bufferObjects = new ArrayList<>(); byte[] bytes = fury.serialize(list, e -> !bufferObjects.add(e)); bufferObjects. .forEach(buf -> buf.writeTo(...)).collect(Collectors.toList()); System.out.println(fury.deserialize(bytes, buffers)); } } ``` -- 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: commits-unsubscr...@fury.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For additional commands, e-mail: commits-h...@fury.apache.org
