[
https://issues.apache.org/jira/browse/FLINK-2788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15173478#comment-15173478
]
ASF GitHub Bot commented on FLINK-2788:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/1744#discussion_r54539847
--- Diff:
flink-core/src/main/java/org/apache/flink/api/common/typeinfo/TypeInformation.java
---
@@ -175,4 +176,39 @@ public boolean isSortKeyType() {
* @return true if obj can be equaled with this, otherwise false
*/
public abstract boolean canEqual(Object obj);
+
+ //
------------------------------------------------------------------------
+
+ /**
+ * Creates a TypeInformation for the type described by the given class.
+ *
+ * <p>This method only works for non-generic types. For generic types,
use the
+ * {@link #of(TypeHint)} method.
+ *
+ * @param typeClass The class of the type.
+ * @param <T> The generic type.
+ *
+ * @return The TypeInformation object for the type described by the
hint.
+ */
+ public static <T> TypeInformation<T> of(Class<T> typeClass) {
--- End diff --
Should we already add an annotation here? I think this will be public API,
right?
> Add type hint with TypeExtactor call on Hint Type
> -------------------------------------------------
>
> Key: FLINK-2788
> URL: https://issues.apache.org/jira/browse/FLINK-2788
> Project: Flink
> Issue Type: Improvement
> Components: Core
> Affects Versions: 0.10.0
> Reporter: Stephan Ewen
> Assignee: Stephan Ewen
> Fix For: 1.0.0
>
>
> As per discussion with [~aljoscha]
> A very good and type safe way to supply type hints would be the following:
> Define a hint class that takes a generic parameter.
> {code}
> public abstract class TypeHint<T> {}
> {code}
> The hints would have the following method:
> {code}
> public DataSet<T> returns(TypeHint<T> hint);
> {code}
> It would be used like this:
> {code}
> DataSet<Sting> data = ...;
> data
> .flatMap( (String str, Collector<Integer> out) -> out.collect(str.length())
> )
> .returns( new TypeHint<Integer>() {})
> {code}
> This would create an inline subclass of the hint, from which the type could
> be extracted. The generics would ensure that it is typesafe.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)