Skip to content

feat: Align object array to collection serialization protocol v2 #2218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

david1437
Copy link

What does this PR do?

Related issues

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

@david1437
Copy link
Author

Some CI tests are failing I am assuming its related to my implementation of the write / copy / read methods? Possibly not using try finally for push / pop generic types?

}
if (this.collectionSerializer != null) {
fury.getGenerics().pushGenericType(this.collectionGenericType);
ArrayAsList list = new ArrayAsList(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we cache this object as a field. Nested serialization is a rare case, if we cache it as a field, we could save object creation cost.

We could write like :

ArrayAsList list = this.list;
if (list == null) {
  list = new ArrayAsList(0);
} else {
  this.list = null
}

// before serialiazation

...


// after serialization

this.list = list

this.collectionSerializer = new FuryArrayAsListSerializer(fury);
this.collectionGenericType = buildCollectionGenericType(dimension);
} else {
this.collectionSerializer = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's null for 1d object array?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought for 1D / Non nested generics that we intended to use the normal default serialization path that was in place before?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only for primitive array. Other array still use Collection serialization protocol. List<String> and String[] should have same layout

Copy link
Author

@david1437 david1437 May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I am under impression T[] can never have primitives only wrapper primitive classes should those use previous method as well ie. Double[] ?

@david1437
Copy link
Author

Any suggestions on running the CI suites locally so I can work on debugging the issues?

@chaokunyang
Copy link
Collaborator

Any suggestions on running the CI suites locally so I can work on debugging the issues?

You can execute:

cd java
mvn -T10 clean install -DskipTests
cd fury-core
mvn test -Dtest=org.apache.fury.serializer.ArraySerializersTest 

Or you can use IDE such jetbrains intellj to debug test one by one, I prefer this method:
image

@david1437
Copy link
Author

So I have been running the ArraySerializerTests and they have all been passing so a bit confused on why the CICD tests are failing

@chaokunyang
Copy link
Collaborator

@david1437 you could execute:

cd java
mvn -T10 clean install -DskipTests
cd fury-core
mvn -T16 test`

All failed tests will be printed in the end

@chaokunyang
Copy link
Collaborator

image
You could download logs to look why if fail

https://github.com/apache/fury/actions/runs/14971961752/job/42054796701?pr=2218

value = this.collectionSerializer.read(buffer).toArray();
fury.getGenerics().popGenericType();
if (this.innerType.isPrimitive() || TypeUtils.isBoxed(this.innerType)) {
return Arrays.copyOf(value, value.length, this.type);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering this does a copy it does not feel good is there a better approach for handling this? without this i get a class cast exception?

@david1437
Copy link
Author

After resolving the issues around primitives and depth increment it seems only a couple tests are failing, Would appreciate some help on those specific failing cases: JdkProxySerializerTest and NonexistentClassSerializersTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants