【问题标题】:Apache beam / Scala Combine perkeyApache Beam / Scala 组合 perkey
【发布时间】:2018-06-01 13:10:48
【问题描述】:

我正在找人提供一个使用 Apache Beam Combine.perkey 转换在 Scala 中使用 beam Java API 的工作示例。

我遇到了 scala/java 类型互操作性的问题。

我无法让每个键组合起来工作。我永远无法让它在语法上是正确的。

例子:

val sales: PCollection KV[(Int,Int), Long]

sales.apply(Combine.perKey[(Int,Int),Long,Long](new SumLongs()))

import org.apache.beam.sdk.transforms.SerializableFunction

class SumLongs extends SerializableFunction[Iterable[Long], Long] {
  override def apply(input: Iterable[Long]): Long = {
  var sum = 0L
  for (item <- input) {
    sum += item
  }
  sum
  }
}

它给出错误,“perkey 的类型参数太多”。当我把它拿出来时,它会显示“未指定的类型参数:OutputT”。

【问题讨论】:

    标签: java scala apache-beam


    【解决方案1】:

    我只需要用 java.lang.Iterable 更改 scala Iterable

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 2019-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多