Home > other >  About the flink keyby problem and Max
About the flink keyby problem and Max

Time:09-24

StreamExecutionEnvironment env=StreamExecutionEnvironment. GetExecutionEnvironment ();
DataStream Ds=env. FromElements (Tuple2. Of (" Tom ", 12), Tuple2) of (" jack ", 20)
, Tuple2. Of (" rose ", 18), Tuple2) of (" Tom ", 20), Tuple2. Of (" jack ", 32)
, Tuple2. Of (" rose ", 11), Tuple2) of (" frank ", 12), Tuple2. Of (67), "putin"
, Tuple2. Of (" frank ", 22), Tuple2) of (" Tom ", 18), Tuple2. Of (99), "putin"
, Tuple2. Of (" jack ", 28), Tuple2) of (" rose ", 19), Tuple2. Of (" putin ", 33)
, Tuple2. Of (" rose ", 88), Tuple2. Of (" jack ", 47), Tuple2. Of (66), "Tom,");
KeyedStream String> Ks=ds. KeyBy (new KeySelector String> () {

@ Override
Public String getKey (Tuple2 & lt; String, Integer> Value) throws the Exception {
The String key=value. F0;
The return key.
}
});
System. The out. Println (Tuple2. Of (" rose ", 18). F0. HashCode ());
System. The out. Println (Tuple2. Of (" frank ", 12). F0. HashCode ());
//ks. Print ();
DataStream St=ks. Max (1);
St. print ();
A confused problems recently learn flink
Excuse me keyby why rose after the partition and frank points into a zone? And why not call Max/min after polymerization keyby partition maximum of partitions?

CodePudding user response:

Why not call Max/min after polymerization keyby partition maximum of partitions? If the input has 3, after Max is also the result of the 3, but the last one is the result of Max, Max (" score "), for example, the original score is 99, 98, 100, 97, the output results, is 99 99 100 100! Read not! Me to explain that the first 99, due to the Max value, so Max is 99, 97-99, the second is small, the output for the storage of Max value of 99, the third big output 100, 100-99, and he is an iterative process,
  • Related