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/e5d62da2c98ad9c6a5ca9c0782a7fea8a01d639a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L124-L144
[2]
https://github.com/apache/flink/blob/e5d62da2c98ad9c6a5ca9c0782a7fea8a01d639a/flink-core/src/main/java/org/apache/flink/api/common/typeinfo/TypeInfo.java
[2]
https://github.com/apache/flink/blob/e5d62da2c98ad9c6a5ca9c0782a7fea8a01d639a/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