Skip to content
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

feat(java): support Ignore inconsistent types deserialize #1737

Merged
merged 28 commits into from
Jul 24, 2024

Conversation

weijiang157152688
Copy link
Contributor

@weijiang157152688 weijiang157152688 commented Jul 18, 2024

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

@weijiang157152688 weijiang157152688 changed the title add IgnoreTypeInconsistentSerializer feat(java):add Ignore type inconsistent deserialize Jul 18, 2024
@weijiang157152688 weijiang157152688 changed the title feat(java):add Ignore type inconsistent deserialize feat(java):support Ignore inconsistent types deserialize Jul 18, 2024
@weijiang157152688 weijiang157152688 changed the title feat(java):support Ignore inconsistent types deserialize feat(java): support Ignore inconsistent types deserialize Jul 18, 2024
}
// Make DescriptorGrouper have consistent order whether field exist or not
// type is inconsistent use serialize type, except enum
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType())
if (!descriptor.getRawType().isAssignableFrom(newDesc.getRawType())

descriptors.add(newDesc);
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete this line

// Make DescriptorGrouper have consistent order whether field exist or not
// type is inconsistent use serialize type, except enum
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType())
&& !descriptor.getRawType().isEnum()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move this check first

}
descriptor = descriptor.copyWithTypeName(newDesc.getTypeName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

add else here

@@ -160,4 +163,53 @@ public void testEmptyObject() {
Fury fury = Fury.builder().requireClassRegistration(true).build();
assertSame(serDe(fury, new Object()).getClass(), Object.class);
}

@Test
public void testIgnoreTypeInconsistentSerializer()
Copy link
Collaborator

@chaokunyang chaokunyang Jul 18, 2024

Choose a reason for hiding this comment

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

Put this to MetaSharedObjectSerializerTest

descriptor = descriptor.copyWithTypeName(newDesc.getTypeName());
descriptors.add(descriptor);
// fury builtin types skip
if (newDesc.getRawType().getTypeName().contains("apache.fury")
Copy link
Collaborator

Choose a reason for hiding this comment

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

newDesc.getRawType().getTypeName().contains("apache.fury") looks too hack, this should be removed

|| newDesc.getRawType().isAssignableFrom(descriptor.getRawType())) {
if (newDesc.getRawType().isEnum()
|| newDesc.getRawType().isAssignableFrom(descriptor.getRawType())
|| newDesc.getRawType().isAssignableFrom(NonexistentClass.NonexistentEnum.class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use org.apache.fury.serializer.NonexistentClass#isNonexistent instead

descriptor = descriptor.copyWithTypeName(newDesc.getTypeName());
descriptors.add(descriptor);
// fury builtin types skip
if (newDesc.getRawType().isEnum()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you make newDesc.getRawType() as a local variable?

Copy link
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

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

LGTM

@chaokunyang chaokunyang merged commit 1a5c357 into apache:main Jul 24, 2024
32 checks passed
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.

3 participants