zhaijp opened a new pull request #7596: Release 1.7 sortPartition bug
URL: https://github.com/apache/flink/pull/7596
 
 
   ### I found a bug when I use sortPartition
   public class WordCountExample {
        public static void main(String[] args) throws Exception {
                final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
                DataSet<String> text = env.fromElements("a b b b b c c");
                DataSet<Tuple2<String,Integer>> wordCounts = text.flatMap(new 
LineSPlitter())
                                .groupBy(0)
                                .sum(1)
                                .sortPartition(1, Order.DESCENDING);
                                
                wordCounts.print();
                
        }
   }
   
   class LineSPlitter implements FlatMapFunction<String, 
Tuple2<String,Integer>>{
   
        @Override
        public void flatMap(String line, Collector<Tuple2<String, Integer>> 
out) throws Exception {
                for(String word : line.split(" ")) {
                        out.collect(new Tuple2<String, Integer>(word,1));
                }
        }
        
   }
   
   ### the console show this:
   (a,1)
   (b,4)
   (c,2)
   
   
   ### when i change the elements aa bb bb bb bb cc cc the result is right:
   (bb,4)
   (cc,2)
   (aa,1)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to