以下代码: val env = StreamExecutionEnvironment.getExecutionEnvironment
val list = new ListBuffer[Tuple3[String,Int,Int]] val random = new Random() for(x<- 0 to 100){ if(random.nextBoolean()){list.append(("INSERT",2,1))}else{ list.append(("UPDATE",2,1)) } } val data = env.fromElements(list).flatMap(_.toList) val keyed=data.keyBy(0).sum(1) keyed.print() val reKeyed=keyed.keyBy(0).sum(2) reKeyed.print() 按理说,reKeyed应该是在keyed的基础上,再进行相加,但是print出来的结果,reKeyed是在原始数据上进行的操作。 这是为什么呢?