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

[AMORO-3356] Include ResourceSerde interface and impl with SimpleSerialize and KryoSerialize #3361

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

czy006
Copy link
Contributor

@czy006 czy006 commented Dec 10, 2024

Include ResourceSerde interface and impl with SimpleSerialize and KryoSerialize

Why are the changes needed?

Close #3356.

Brief change log

  • Add ResourceSerde interface for serialize and deserialize
  • SimpleSerialize/KryoSerialize/JavaSerializer impl for ResourceSerde

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

Copy link
Member

@klion26 klion26 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, left some comments, please take a look when you're free.


import java.io.Serializable;

public class JavaSerializer<R extends Serializable> implements ResourceSerde<R> {
Copy link
Member

Choose a reason for hiding this comment

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

Could we add some doc for this?


public class JavaSerializer<R extends Serializable> implements ResourceSerde<R> {

private static final KryoSerialize kryoSerialize = new KryoSerialize<>();
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason to use raw type here? can we change to KryoSerialize<Object> or KryoSerialize<R> or something else?

Copy link
Member

Choose a reason for hiding this comment

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

It seems we use KryoSerialize to de/serialize for JavaSerializer, is this the expected behavior?

try {
return KRYO_SERIALIZER.get().serialize(resource);
} catch (Exception e) {
throw new IllegalArgumentException("serialization error of " + resource, e);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to catch and rethrow the exception here?

*
* @param resource input object
*/
byte[] serializeResource(R resource);
Copy link
Member

Choose a reason for hiding this comment

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

not sure do we need to throw checked exception for serialzieResource and deserializeResource here


final class DeserializedResource<R> {
private final R resource;
private final boolean modifiedDuringDeserialization;
Copy link
Member

Choose a reason for hiding this comment

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

Is modifiedDuringDeserialization this for future usage? it seems hasn't been used now.

Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask]: Include ResourceSerde interface and impl with SimpleSerialize and KryoSerialize
2 participants