Skip to content

Commit

Permalink
chore(java): add fury deep copy documentation (#1773)
Browse files Browse the repository at this point in the history
## What does this PR do?

add fury deep copy documentation

## Related issues

Closes #1772

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?


## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
  • Loading branch information
chaokunyang authored Jul 27, 2024
1 parent fd39760 commit 7517c23
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions docs/guide/java_serialization_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ 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;
Fury f = Fury.builder().withLanguage(Language.JAVA)
.withClassLoader(classLoader).build();
f.register(SomeClass.class);
return f;
});

public static void main(String[] args) {
Expand Down Expand Up @@ -115,6 +115,7 @@ public class Example {
| `codeGenEnabled` | Disabling may result in faster initial serialization but slower subsequent serializations. | `true` |
| `asyncCompilationEnabled` | If enabled, serialization uses interpreter mode first and switches to JIT serialization after async serializer JIT for a class is finished. | `false` |
| `scalaOptimizationEnabled` | Enables or disables Scala-specific serialization optimization. | `false` |
| `copyRef` | When disabled, the copy performance will be better. But fury deep copy will ignore circular and shared reference. Same reference of an object graph will be copied into different objects in one `Fury#copy`. | `true` |

## Advanced Usage

Expand Down Expand Up @@ -192,6 +193,29 @@ not worthy compared to performance cost. Maybe you should try to disable long co
much
space savings.

### Object deep copy

Deep copy example:

```java
Fury fury=Fury.builder()
...
.withRefCopy(true).build();
SomeClass a=xxx;
SomeClass copied=fury.copy(a)
```

Make fury deep copy ignore circular and shared reference, this deep copy mode will ignore circular and shared reference.
Same reference of an object graph will be copied into different objects in one `Fury#copy`.

```java
Fury fury=Fury.builder()
...
.withRefCopy(false).build();
SomeClass a=xxx;
SomeClass copied=fury.copy(a)
```

### Implement a customized serializer

In some cases, you may want to implement a serializer for your type, especially some class customize serialization by
Expand Down

0 comments on commit 7517c23

Please sign in to comment.