flink-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Neutatz <neut...@googlemail.com>
Subject Very strange behaviour of groupBy() -> sort() -> first()
Date Wed, 21 Jan 2015 18:18:07 GMT

my use case is the following:

I have a Tuple2<String,Long>. I want to group by the String and sum up the
Long values accordingly. This works fine with these lines:

DataSet<Lineitem> lineitems = getLineitemDataSet(env);
lineitems.project(new int []{3,0}).groupBy(0).aggregate(Aggregations.SUM,

After the aggregation I want to print the 10 groups with the highest sum,

string1, 100L
string2, 50L
string3, 1L

I tried that:

lineitems.project(new int []{3,0}).groupBy(0).aggregate(Aggregations.SUM,
1).groupBy(0).sortGroup(1, Order.DESCENDING).first(3).print();

But instead of 3 records, I get a lot more.

Can see my error?

Best regards,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message