Skip to content

[HUDI-6617] make HoodieRecordDelegate implement KryoSerializable#9327

Merged
danny0405 merged 6 commits intoapache:masterfrom
eric9204:HUDI-6617
Aug 5, 2023
Merged

[HUDI-6617] make HoodieRecordDelegate implement KryoSerializable#9327
danny0405 merged 6 commits intoapache:masterfrom
eric9204:HUDI-6617

Conversation

@eric9204
Copy link
Contributor

@eric9204 eric9204 commented Aug 1, 2023

Change Logs

make HoodieRecordDelegate implement KryoSerializable

Impact

Improve serialize/deserialize performance.

Risk level (write none, low medium or high below)

NONE

Documentation Update

NONE

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

this.currentLocation = newrl == null ? Option.empty() : Option.of(newrl);
HoodieRecordLocation oldrl = (HoodieRecordLocation) kryo.readClassAndObject(input);
this.newLocation = oldrl == null ? Option.empty() : Option.of(oldrl);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Option.ofNullable ? Can we write some tests for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been updated

record.setNewLocation(new HoodieRecordLocation("001", "file-01"));
hoodieRecordDelegate = HoodieRecordDelegate.fromHoodieRecord(record);

kryo.register(HoodieRecordDelegate.class, new JavaSerializer());
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we do not register the class in Kryo, does it sill use the kryo ser/deser ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been updated

}

@Test
public void TestSerializeDeserialize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void TestSerializeDeserialize() {
public void testKryoSerializeDeserialize() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been updated

Kryo kryo = new Kryo();
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
Output output = new Output(baos);
hoodieRecordDelegate.write(kryo, output);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not very familiar with Kryo, do we need to register explicitly the class for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your reminding.
Yes, it's necessary to register hudi specific classes. HoodieRecordDelegate has been added to HoodieCommonKryoRegistrar, that make sure the ordering of the registration could not change.


// Register serializers
kryo.register(Utf8.class, new SerializationUtils.AvroUtf8Serializer());
kryo.register(GenericData.Fixed.class, new GenericAvroSerializer<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a registration for avro classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the member variable types of HoodieRecordDelegate don't contain avro.that should't be registered.
Has been updated.

@hudi-bot
Copy link
Collaborator

hudi-bot commented Aug 3, 2023

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@nsivabalan
Copy link
Contributor

@prashantwason can you review

@danny0405
Copy link
Contributor

@danny0405 danny0405 added the area:performance Performance optimizations label Aug 4, 2023
@danny0405 danny0405 merged commit a2db1a9 into apache:master Aug 5, 2023
@danny0405
Copy link
Contributor

@prashantwason I'm gonna merge it first, maybe you can revise it before the release.

@eric9204 eric9204 deleted the HUDI-6617 branch August 24, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:performance Performance optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants