Home > other >  About the flink keyby and Max/min
About the flink keyby and Max/min

Time:10-11

Recently learn flink, wrote a ` ` ` 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.
}
}); ` ` `
But found that rose after the print to print and frank were assigned to the same group, is this why? I see keby through hashcode implementation, but the two hashcode is different?
There is a ` ` ` DataStream St=ks. Max (1); ` ` ` print found after return is not Integer maximum value of each group of elements, get a half a day do not understand, do you have one who can explain?
  • Related