[
https://issues.apache.org/jira/browse/FLINK-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14226539#comment-14226539
]
Stephan Ewen commented on FLINK-1255:
-------------------------------------
[~ssc] Do you think this is a fair workaround?
I think we should have an FAQ entry on this error in any case.
> Problems with generic types in Scala API
> ----------------------------------------
>
> Key: FLINK-1255
> URL: https://issues.apache.org/jira/browse/FLINK-1255
> Project: Flink
> Issue Type: Bug
> Components: Scala API
> Affects Versions: 0.7.0-incubating
> Reporter: Sebastian Schelter
>
> the code below produces the following exception:
> {noformat}
> Error:(47, 18) could not find implicit value for evidence parameter of type
> org.apache.flink.api.common.typeinfo.TypeInformation[K]
> data.groupBy { extractKey }
> {noformat}
> Fixing K to Long made the code run though
> {noformat}
> def groupCount[T, K](data: DataSet[T], extractKey: (T) => K): DataSet[(K,
> Long)] = {
> data.groupBy { extractKey }
> .reduceGroup { group => countBy(extractKey, group) }
> }
> private[this] def countBy[T, K](extractKey: T => K,
> group: Iterator[T]): (K, Long) = {
> val key = extractKey(group.next())
> var count = 1L
> while (group.hasNext) {
> group.next()
> count += 1
> }
> key -> count
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)