Skip to content

Commit

Permalink
feat(java): use SubListViewSerializer only when tracking ref (#1858)
Browse files Browse the repository at this point in the history
## What does this PR do?

use SubListViewSerializer only when tracking ref

## Related issues
Closes #1198

#1856 

## 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 Sep 27, 2024
1 parent 5c82798 commit da57b79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public static void registerSerializers(Fury fury, boolean preserveView) {
new Class[] {
SubListClass, RandomAccessSubListClass, ArrayListSubListClass, ImmutableSubListClass
}) {
if (preserveView && fury.getConfig().getLanguage() == Language.JAVA) {
fury.registerSerializer(cls, new SubListViewSerializer(fury, (Class<List>) cls));
if (fury.trackingRef() && preserveView && fury.getConfig().getLanguage() == Language.JAVA) {
fury.registerSerializer(cls, new SubListViewSerializer(fury, cls));
} else {
fury.registerSerializer(cls, new SubListSerializer(fury, (Class<List>) cls));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class SubListSerializersTest extends FuryTestBase {
@Test
public void testSubListViewSerialization() {
Fury fury = builder().build();
Fury fury = builder().withRefTracking(true).build();
List<Integer> data = new ArrayList<>();
Collections.addAll(data, 1, 2, 3, 4, 5, 6, 7);
int length = fury.serialize(data).length;
Expand Down Expand Up @@ -65,8 +65,7 @@ public void testSubListViewSerialization() {

@Test
public void testSubListNoViewSerialization() {
Fury fury = builder().build();
SubListSerializers.registerSerializers(fury, false);
Fury fury = builder().withRefTracking(false).build();
List<Integer> data = new ArrayList<>();
Collections.addAll(data, 1, 2, 3, 4, 5, 6, 7);
int length = fury.serialize(data).length;
Expand Down

0 comments on commit da57b79

Please sign in to comment.