Java type erasure and object reuse

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

Java type erasure and object reuse

Greg Hogan
What is best practice for handling Java type erasure in user defined
functions? Is there a means by which the TypeInformation can be accessed
from a RichFunction? My temporary solution was to add a "T copy()" method
to the CopyableValue interface.

A common use case is a GroupReduceFunction that needs to collect objects.
With object reuse we need to make a copy and with type erasure we cannot
call new.

Greg Hogan
Reply | Threaded
Open this post in threaded view
|

Re: Java type erasure and object reuse

Stephan Ewen
Good problem...

We were thinking for a while to make the input and output type serializers
available from the RuntimeContext.
That way you could call "T copy = serializer.copy(inValue)".

The "copy()" method on the copyable value is actually a good addition
nonetheless!


On Thu, Sep 17, 2015 at 10:31 PM, Greg Hogan <[hidden email]> wrote:

> What is best practice for handling Java type erasure in user defined
> functions? Is there a means by which the TypeInformation can be accessed
> from a RichFunction? My temporary solution was to add a "T copy()" method
> to the CopyableValue interface.
>
> A common use case is a GroupReduceFunction that needs to collect objects.
> With object reuse we need to make a copy and with type erasure we cannot
> call new.
>
> Greg Hogan
>