Skip to content

Commit 6613de0

Browse files
Hen1nghening
and
hening
authored
fix(java): use serialization binding (#2241)
<!-- **Thanks for contributing to Fury.** **If this is your first time opening a PR on fury, you can refer to [CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).** Contribution Checklist - The **Apache Fury (incubating)** community has restrictions on the naming of pr titles. You can also find instructions in [CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md). - Fury has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here. --> ## What does this PR do? <!-- Describe the purpose of this PR. --> ## Related issues <!-- Is there any related issue? Please attach here. - #xxxx0 - #xxxx1 - #xxxx2 --> ## 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. --> Co-authored-by: hening <[email protected]>
1 parent 1d4d35e commit 6613de0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

java/fury-core/src/main/java/org/apache/fury/serializer/NonexistentClassSerializers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ public void write(MemoryBuffer buffer, Object v) {
130130
// whether tracking ref is recorded in `fieldInfo.serializer`, so it's still
131131
// consistent with jit serializer.
132132
Serializer<Object> serializer = classInfo.getSerializer();
133-
fury.writeRef(buffer, fieldValue, serializer);
133+
binding.writeRef(buffer, fieldValue, serializer);
134134
} else {
135-
fury.writeRef(buffer, fieldValue, classInfo);
135+
binding.writeRef(buffer, fieldValue, classInfo);
136136
}
137137
}
138138
}
139139
for (ObjectSerializer.GenericTypeField fieldInfo : fieldsInfo.otherFields) {
140140
Object fieldValue = value.get(fieldInfo.qualifiedFieldName);
141141
boolean nullable = fieldInfo.nullable;
142142
if (fieldInfo.trackingRef) {
143-
fury.writeRef(buffer, fieldValue, fieldInfo.classInfoHolder);
143+
binding.writeRef(buffer, fieldValue, fieldInfo.classInfoHolder);
144144
} else {
145145
binding.writeNullable(buffer, fieldValue, fieldInfo.classInfoHolder, nullable);
146146
}

java/fury-core/src/main/java/org/apache/fury/serializer/SerializationBinding.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface SerializationBinding {
4141

4242
void writeRef(MemoryBuffer buffer, Object obj, ClassInfoHolder classInfoHolder);
4343

44+
void writeRef(MemoryBuffer buffer, Object obj, ClassInfo classInfo);
45+
4446
void writeNonRef(MemoryBuffer buffer, Object obj);
4547

4648
void writeNonRef(MemoryBuffer buffer, Object obj, ClassInfo classInfo);
@@ -124,6 +126,11 @@ public void writeRef(MemoryBuffer buffer, Object obj, ClassInfoHolder classInfoH
124126
fury.writeRef(buffer, obj, classInfoHolder);
125127
}
126128

129+
@Override
130+
public void writeRef(MemoryBuffer buffer, Object obj, ClassInfo classInfo) {
131+
fury.writeRef(buffer, obj, classInfo);
132+
}
133+
127134
@Override
128135
public <T> T readRef(MemoryBuffer buffer, Serializer<T> serializer) {
129136
return fury.readRef(buffer, serializer);
@@ -317,6 +324,11 @@ public void writeRef(MemoryBuffer buffer, Object obj, ClassInfoHolder classInfoH
317324
fury.xwriteRef(buffer, obj);
318325
}
319326

327+
@Override
328+
public void writeRef(MemoryBuffer buffer, Object obj, ClassInfo classInfo) {
329+
fury.xwriteRef(buffer, obj);
330+
}
331+
320332
@Override
321333
public <T> T readRef(MemoryBuffer buffer, Serializer<T> serializer) {
322334
return (T) fury.xreadRef(buffer, serializer);

0 commit comments

Comments
 (0)