Hi Richard,
Same problem, 12 Flink versions later,
I created my own TypeInformation/Serializer/Snapshot for UUID (Scala in that
case), along:
class UUIDTypeInformation extends TypeInformation[UUID]
…
class UUIDSerializer extends TupleSerializerBase[UUID](
…
class UUIDSerializerSnapshot(serializer: UUIDSerializer) extends
CompositeTypeSerializerSnapshot[UUID, UUIDSerializer](serializer) {
…
Altogether 100 lines of code, implementation is simple, you only need to
implement the respective apis and ‘follow the types’
And the register the UUIDTypeInformation with the Flink type system.
… unfortunately I haven’t got the permission to share the code …
Hope that helps 😊
This
From: Zhanghao Chen <[email protected]>
Sent: Wednesday, May 14, 2025 3:00 AM
To: Richard Cheung <[email protected]>; [email protected]
Subject: [External] Re: Apache Flink Serialization Question
⚠EXTERNAL MESSAGE – CAUTION: Think Before You Click ⚠
Flink still use PojoSerializer for the class while only using Kryo for the UUID
field.
Best,
Zhanghao Chen
________________________________
From: Richard Cheung <[email protected]<mailto:[email protected]>>
Sent: Wednesday, May 14, 2025 3:21
To: [email protected]<mailto:[email protected]>
<[email protected]<mailto:[email protected]>>
Subject: Apache Flink Serialization Question
Hi all!
I have a question about serialization of POJO data classes in Apache Flink v1.8
(Java). Here's some context:
One of my data classes was initially not POJO compatible as it had final fields
and no no-arg constructor. I removed the final modifiers and added a no-arg
constructor, and confirmed that the serializer switched from KryoSerializer to
PojoSerializer using TypeInformation and TypeSerializer to log the info.
However, one of the fields in the class is a java.util.UUID, which is not POJO
compatible. I see a log message saying that the UUID field cannot be used as a
POJO type. The logs also say that the UUID field will be processed as a generic
type which means that, to my knowledge, the KryoSerializer will be used. These
logs appear after the one indicating that the PojoSerializer is being used for
my data class.
My question is:
Does the presence of the UUID field cause the entire class to be serialized
with KryoSerializer or does Flink still use PojoSerializer for the class while
only using Kryo for the UUID field?
Best regards,
Richard
Diese Nachricht ist ausschliesslich für den Adressaten bestimmt und beinhaltet
unter Umständen vertrauliche Mitteilungen. Da die Vertraulichkeit von
e-Mail-Nachrichten nicht gewährleistet werden kann, übernehmen wir keine
Haftung für die Gewährung der Vertraulichkeit und Unversehrtheit dieser
Mitteilung. Bei irrtümlicher Zustellung bitten wir Sie um Benachrichtigung per
e-Mail und um Löschung dieser Nachricht sowie eventueller Anhänge. Jegliche
unberechtigte Verwendung oder Verbreitung dieser Informationen ist streng
verboten.
This message is intended only for the named recipient and may contain
confidential or privileged information. As the confidentiality of email
communication cannot be guaranteed, we do not accept any responsibility for the
confidentiality and the intactness of this message. If you have received it in
error, please advise the sender by return e-mail and delete this message and
any attachments. Any unauthorised use or dissemination of this information is
strictly prohibited.