September 2017
Beginner to intermediate
360 pages
8h 13m
English
Before moving to transformation functions, let's have a look at an example of DataStream. The following code snippet is a word count example implemented using DataStream API:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();DataStream<Tuple2<String, Integer>> dataStream = env.socketTextStream("localhost", 9999).flatMap(new Splitter()).keyBy(0).timeWindow(Time.seconds(5)).sum(1);
StreamExecutionEnviornment is used to create a DataStream Object. In the previous example, the environment first connects with the source of data using a socket. Then we apply flatMap function which splits the sentence into a tuple of words and count it as 1. KeyBy is used to group the stream on the basis of key ...
Read now
Unlock full access