You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Bart van Deenen <ba...@fastmail.fm> on 2016/03/22 13:23:35 UTC
Re: Scala syntax AllWindowFunction ? Found it myself.
val aggregatedStream = stream.apply( (w:Window, values:
scala.Iterable[(List[String], Long, Int)], out:
Collector[Aggregation]) => {
import scala.collection.JavaConversions._
val agg = Aggregation( values.toList.map {
case (pages, _, ct) => (ct, pages)
})
out.collect(agg)
})
Pheew.
--
Bart van Deenen
bartvandeenen@fastmail.fm
On Tue, Mar 22, 2016, at 12:40, Bart van Deenen wrote:
>
> Hi all
>
> I'm using 1.0, and have all my data nicely bundled in one allWindow, but
> I don't understand the syntax in Scala to make on json out of those for
> dumping the whole window into Kafka.
>
> My type is:
>
> val stream: AllWindowedStream[(List[String], Long, Int), TimeWindow]
>
> and I want to do
>
> stream.apply ????????
>
> I've tried to convert the Java example from the documentation to Scala,
> but I can't get anything meaningful to compile
>
> allWindowedStream.apply (new AllWindowFunction<Tuple2<String,Integer>,
> Integer, Window>() {
> public void apply (Window window,
> Iterable<Tuple2<String, Integer>> values,
> Collector<Integer> out) throws Exception {
> int sum = 0;
> for (value t: values) {
> sum += t.f1;
> }
> out.collect (new Integer(sum));
> }
> });
>
>
> Help very appreciated!
>
> Greetings
>
>
> --
> Bart van Deenen
> bartvandeenen@fastmail.fm