Flink学習ノート---DataStream Transformations


Stream Transformations
1.Map:
DataSteam -> DataSteam
dataSteam.map {x => x * 2}

2.FlatMap
DataStream -> DataStream
dataStream.flatMap {str => str.split(" ")}

3.Filter
DataStream -> DataStream
dataStream.filter { _ != 0 }

4.KeyBy
DataStream -> KeyedStream
dataStream.keyBy("someKey")
dataStream.keyBy("0")

5.Reduce
KeyedStream -> DataStream
keyedStream.reduce { _ + _ }

6.Fold
keyedStream -> DataSyteam
val result: DataStream[String] = keyedStream.fold("start")((str, i)) => { str + "-" + i })

7.Aggregation
KeyedStream -> DataStream
keyedStream.sum(0)
KeyedStream.sum("key")
keyedStream.min(0)
keyedStream.min("key")
keyedStream.max(0)
keyedStream.max("key")
keyedStream.minBy(0)
keyedStream.minBy("key")
keyedStream.maxBy(0)
keyedStream.maxBy("key")

8.Window
keyedSteam -> windowedStream
dataStream.keyBy(0).window(TumblingEventTimeWindow.of(Time.second(5)))

9