Sebastian Schelter created FLINK-1255:
-----------------------------------------

             Summary: 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)

Reply via email to