zendesk / scala-flow

A lightweight library intended to make developing Google DataFlow jobs in Scala easier.
Apache License 2.0
14 stars 1 forks source link

combine perkey #18

Closed alistairmcintyre closed 6 years ago

alistairmcintyre commented 6 years ago

Do you have a working example of Combine.perkey? I can't get combine per key to work. I can never get it to be correct in syntax.

Example - 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 } }

It either complains that "too many arguments provided for perkey", or when I take that out, it states I'm missing parameter for OutputT.

Thanks, Alistair