Hi Alex,

I guess your "real" constuctor is invoked by your code within your Flink program. The default constructor is used during serialization between operators. If you are interested in the internals, you can have a look at the PojoSerializer [1]. The POJO is created with the default constrcutor and then filled. If you want to reduce the calls of constructors you can also enable the object reuse mode [2] but this requires your code to be correct to prevent side effects.


Regards,
Timo


[1] https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java [2] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/batch/#operating-on-data-objects-in-functions

Am 09.03.18 um 21:24 schrieb NEKRASSOV, ALEXEI:

Hi,

I added a default constructor to the class that represents messages flowing through my Flink job graph – to satisfy Flink POJO requirements.

Although I don’t call that default constructor explicitly, the logs show that it is called anyway.

Why is this happening?

In my test, for 77 incoming messages I see 77 calls to my “real” constructor, but also another 77 calls – to default constructor, that essentially create objects with no value.

Is this expected, or I’m doing something wrong?

Thanks,

Alex Nekrassov

nekras...@att.com <mailto:nekras...@att.com>


Reply via email to