很多案例中:
DataStream<Tuple2<String, Integer>> resultStream =
inputDataStream.flatMap(new WordCount.MyFlatMapper())
.keyBy(0) // 这里弃用
.sum(1);
改为:
DataStream<Tuple2<String, Integer>> resultStream =
inputDataStream.flatMap(new WordCount.MyFlatMapper())
.keyBy(tuple -> tuple.f0) // 修改后,使用tuple.f0表示第0个位置的信息
.sum(1);