You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/01/30 01:38:46 UTC

[GitHub] zhaijp opened a new pull request #7596: Release 1.7 sortPartition bug

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:
users@infra.apache.org


With regards,
Apache Git Services