Search code examples
scalaapache-kafkadslapache-kafka-streamskafka-streams-scala

Getting unspecified value parameter scala Kafka


Hi I am getting this compilation error -

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

But I clearly have an aggregator there already. Does anyone know what's going on?

 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 }

Solution

  • You can only use the {} form of method call to pass a single parameter, which is treated as a block. You need to pass two parameters, so use () instead:

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