Hi Alexander,

I guess that Timo will be able to give a more detailed answer, but I agree
with your assessment. The TypeInfo annotation does not solve all the
problems as you've stated. Thus, making the TypeExtractor.registerFactory
method public would solve the problem. I'm just wondering whether the user
should have to deal with the TypeExtractor directly or whether offering a
respective method at the ExecutionConfig would be better.

I've create a corresponding JIRA ticket [1].

I checked and you should have access rights with your account registered
under alexander.s.alexandrov@...

[1] https://issues.apache.org/jira/browse/FLINK-4783

Cheers,
Till

On Sat, Oct 8, 2016 at 4:20 PM, Alexander Alexandrov <
alexander.s.alexand...@gmail.com> wrote:

> To follow up on my on post,
>
> I think a straight-forward approach would be to make the
> `TypeExtractor.registerFactory` method public [1].
>
> BTW, both the TypeInfo annotation [2] and TypeInfoFactory [3] itself refer
> to this method in the JavaDoc. However, besides these mentions I was not
> able to find any actual usage of `registerFactory` in the Flink codebase,
> so I am not sure when and where the method is actually invoked to register
> the annotated classes.
>
> [1]
> https://github.com/apache/flink/blob/e5d62da2c98ad9c6a5ca9c0782a7fe
> a8a01d639a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/
> TypeExtractor.java#L124-L144
> [2]
> https://github.com/apache/flink/blob/e5d62da2c98ad9c6a5ca9c0782a7fe
> a8a01d639a/flink-core/src/main/java/org/apache/flink/
> api/common/typeinfo/TypeInfo.java
> [2]
> https://github.com/apache/flink/blob/e5d62da2c98ad9c6a5ca9c0782a7fe
> a8a01d639a/flink-core/src/main/java/org/apache/flink/api/common/typeinfo/
> TypeInfoFactory.java
>
> On Sat, Oct 8, 2016 at 4:00 PM Alexander Alexandrov <
> alexander.s.alexand...@gmail.com> wrote:
>
> I wanted to open this directly as a JIRA to follow-up on FLINK-3042,
> however my account (aalexandrov) does not seem to have the necessary
> privileges, so I will post this to the dev list instead.
>
> The current approach for registration of custom `TypeInformation`
> implementations which relies exclusively on annotations. Consequently, it
> will be very tedious to create a custom `TypeInformation` for types that
> are pulled and used within a project from an external library.
>
> For example, if  I have a project structure such as
>
> ```
> my-project      // uses FancyContainer<A>
>  `- flink-core
>  `- ext-library // defines FancyContainer<A>
> ```
>
> I will not be able to modify `FancyContainer.java`.
>
> A workaround that might work (I have not tested it yet) is to use
> `javassist` to attach the annotation prior to job assembly, but IMHO a much
> clearer solution would be to extend the `ExecutionEnvironment` with
> something like
>
> ```java
> env.getConfig().registerTypeInfoFactory(Class<?> type, Class<? extends
> TypeInfofactory<?>> factory)
> ```
>
> Regards,
> Alexander
>

Reply via email to