获取未指定值的参数scala kafka

lmvvr0a8  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(372)

嗨,我得到这个编译错误-

Unspecified Value parameters: aggregator: (String, String, NotInferedVR) => NotInferedVR

但我显然已经有了一个聚合器。有人知道发生了什么事吗?

val stream = builder
    .stream(inputTopic)(Consumed.`with`(Serdes.String(), Serdes.ByteArray()))
    .map{ (key: String, value: Array[Byte]) =>
      println(s"key = ${key}")
      val lv = GroupByAction.convertByteArrayToJsonObject(value)
      val lst = List.empty[String]
      val newKey = GroupByAction
        .reKey(lv
          , groupByColumnList
            .asScala
            .toList
          ,lst)
      val newValue = getValFromJSONMessage(lv, aggregateColumnList.asScala.toList.head)
      println(s"newKey = ${newKey}")
      (newKey, newValue)}
    .groupByKey(Serialized.`with`(Serdes.String(), Serdes.String()))
    .aggregate{ () => 0.toString, (k,v,vr: Long) => (v.toString.toLong + vr.toString.toLong).toString }
klsxnrf1

klsxnrf11#

你只能使用 {} 传递单个参数的方法调用的形式,该参数被视为块。你需要传递两个参数,所以使用 () 取而代之的是:

aggregate( () => 0.toString, (k,v,vr: Long) => (v.toString.toLong + vr.toString.toLong).toString )

相关问题