chaokunyang commented on code in PR #170:
URL: https://github.com/apache/fury-site/pull/170#discussion_r1730377531
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java_serialization_guide.md:
##########
@@ -0,0 +1,426 @@
+---
+title: Java 序列化指南
+sidebar_position: 0
+id: java_object_graph_guide
+---
+
+## Java 对象图序列化
+
+当只需要 Java 对象序列化时,其相比跨语言的图序列化拥有更好的性能。
+
+## 快速开始
+
+注意:Fury 对象创建的代价很高, 因此 **Fury 对象应该尽可能被复用**,而不是每次都重新创建。
+
+您应该创建一个全局的静态变量,或者单例变量和受限制的 Fury 变量。
+
+Fury 单线程用法:
+
+```java
+import java.util.List;
+import java.util.Arrays;
+
+import org.apache.fury.*;
+import org.apache.fury.config.*;
+
+public class Example {
+ public static void main(String[] args) {
+ SomeClass object = new SomeClass();
+ // Note that Fury instances should be reused between
+ // multiple serializations of different objects.
+ Fury fury = Fury.builder().withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build();
+ // Registering types can reduce class name serialization overhead, but not
mandatory.
+ // If class registration enabled, all custom types must be registered.
+ fury.register(SomeClass.class);
+ byte[] bytes = fury.serialize(object);
+ System.out.println(fury.deserialize(bytes));
+ }
+}
+```
+
+Fury 多线程用法:
+
+```java
+import java.util.List;
+import java.util.Arrays;
+
+import org.apache.fury.*;
+import org.apache.fury.config.*;
+
+public class Example {
+ public static void main(String[] args) {
+ SomeClass object = new SomeClass();
+ // Note that Fury instances should be reused between
+ // multiple serializations of different objects.
+ ThreadSafeFury fury = new ThreadLocalFury(classLoader -> {
+ Fury f = Fury.builder().withLanguage(Language.JAVA)
+ .withClassLoader(classLoader).build();
+ f.register(SomeClass.class);
+ return f;
+ });
+ byte[] bytes = fury.serialize(object);
+ System.out.println(fury.deserialize(bytes));
+ }
+}
+```
+
+Fury 对象复用示例:
+
+```java
+import java.util.List;
+import java.util.Arrays;
+
+import org.apache.fury.*;
+import org.apache.fury.config.*;
+
+public class Example {
+ // reuse fury.
+ private static final ThreadSafeFury fury = new ThreadLocalFury(classLoader
-> {
+ Fury f = Fury.builder().withLanguage(Language.JAVA)
+ .withClassLoader(classLoader).build();
+ f.register(SomeClass.class);
+ return f;
+ });
+
+ public static void main(String[] args) {
+ SomeClass object = new SomeClass();
+ byte[] bytes = fury.serialize(object);
+ System.out.println(fury.deserialize(bytes));
+ }
+}
+```
+
+## FuryBuilder 参数选项
+
+| 参数选项名 | 描述
| 默认值
|
+|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
+| `timeRefIgnored` | 启用 reference tracking 时,是否忽略在
`TimeSerializers` 中注册的所有时间类型及其子类的引用跟踪。如果忽略,则可以通过调用
`Fury#registerSerializer(Class, Serializer)`
来启用对每种时间类型的引用跟踪。例如,`fury.registerSerializer(Date.class, new
DateSerializer(fury, true))`。请注意,启用 ref tracking
功能应在任何包含时间字段的类型的序列化程序编码之前进行。否则,这些字段仍将跳过 reference tracking。 | `true`
|
+| `compressInt` | 启用或禁用 int 压缩,减小数据体积。
| `true`
|
+| `compressLong` | 启用或禁用 long 压缩,减小数据体积。
| `true`
|
+| `compressString` | 启用或禁用 String 压缩,减小数据体积。
| `true`
|
+| `classLoader` | 不应更新类加载器;Fury 会缓存类元数据。使用
`LoaderBinding` 或 `ThreadSafeFury` 进行类加载器更新。
| `Thread.currentThread().getContextClassLoader()`
|
Review Comment:
```suggestion
| `classLoader` | 关联到当前 Fury 的类加载器,每个 Fury
会关联一个不可变的类加载器,用于缓存类元数据。如果需要切换类加载器,请使用 `LoaderBinding` 或 `ThreadSafeFury` 进行更新。
|
`Thread.currentThread().getContextClassLoader()` |
```
--
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]