PojoComparator question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PojoComparator question

Gábor Horváth
Hi!

While I was working on code generation support for PojoComparators, I
stumbled upon the compareSerialized method [1]. It first creates two new
instances and then it is using the reusing overloads of the serializer.
Calling the non-reusing overload would create the instance anyways. Is
there a reason why the reusing overload is used here?

Regards,
Gábor

[1]
https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java#L277
Reply | Threaded
Open this post in threaded view
|

Re: PojoComparator question

Aljoscha Krettek-2
Hi,
I think this is an artifact from the past. Using the "non-reuse"
deserialize seems more correct, especially in the presence of subclasses.

Best,
Aljoscha

On Mon, 30 May 2016 at 19:13 Gábor Horváth <[hidden email]> wrote:

> Hi!
>
> While I was working on code generation support for PojoComparators, I
> stumbled upon the compareSerialized method [1]. It first creates two new
> instances and then it is using the reusing overloads of the serializer.
> Calling the non-reusing overload would create the instance anyways. Is
> there a reason why the reusing overload is used here?
>
> Regards,
> Gábor
>
> [1]
>
> https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java#L277
>
Reply | Threaded
Open this post in threaded view
|

Re: PojoComparator question

Stephan Ewen
The "compareSerialized" should probably internally always reuse instances,
where possible.
Since these are never passed into user code or anything, that should be
okay to do.

On Tue, May 31, 2016 at 11:52 AM, Aljoscha Krettek <[hidden email]>
wrote:

> Hi,
> I think this is an artifact from the past. Using the "non-reuse"
> deserialize seems more correct, especially in the presence of subclasses.
>
> Best,
> Aljoscha
>
> On Mon, 30 May 2016 at 19:13 Gábor Horváth <[hidden email]> wrote:
>
> > Hi!
> >
> > While I was working on code generation support for PojoComparators, I
> > stumbled upon the compareSerialized method [1]. It first creates two new
> > instances and then it is using the reusing overloads of the serializer.
> > Calling the non-reusing overload would create the instance anyways. Is
> > there a reason why the reusing overload is used here?
> >
> > Regards,
> > Gábor
> >
> > [1]
> >
> >
> https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java#L277
> >
>