title: Apache Flink - groupBy
body: <p>I am trying to follow the first exercise on <a href="http://dataartisans.github.io/flink-training/exercises/" rel="nofollow">http://dataartisans.github.io/flink-training/exercises/</a>.</p>
  
  <p>Now I come to the following problem. What does the <code>groupBy</code> function give me back? And how does the <code>foldLeft</code> method transform that - for me unknown - result?</p>
  
  <p>The code is the following:</p>
  
  <pre><code>mails.map {
            m =&gt; (m._1.substring(0, 7), m._2.substring(m._2.lastIndexOf("&lt;") + 1, m._2.length - 1))
          }
          .groupBy(0, 1)
          .reduceGroup( ms =&gt; ms.foldLeft("", "", 0)( (c, m) =&gt; (m._1, m._2, c._3 + 1) ) )
  </code></pre>
  
  <p>Regards,
  Kevin</p>