title: Are multiple reduceByKey on the same RDD compiled into a single scan?
body: <p>Suppose I have an RDD (50M records/dayredu) which I want to summarize in several different ways. 
  The RDD records are 4-tuples: <code>(keep, foo, bar, baz)</code>. </p>
  
  <ul>
  <li><code>keep</code> - boolean </li>
  <li><code>foo</code>, <code>bar</code>, <code>baz</code> - 0/1 int</li>
  </ul>
  
  <p>I want to count how many of each of the <code>foo</code> &amp;c are kept and dropped, i.e., I have to do the following for <code>foo</code> (and the same for <code>bar</code> and <code>baz</code>):</p>
  
  <pre><code>rdd.filter(lambda keep, foo, bar, baz: foo == 1)
     .map(lambda keep, foo, bar, baz: keep, 1)
     .reduceByKey(operator.add)
  </code></pre>
  
  <p>which would return (after <code>collect</code>) a list like <code>[(True,40000000),(False,10000000)]</code>.</p>
  
  <p>The question is: is there an <strong><em>easy</em></strong> way to avoid scanning <code>rdd</code> 3 times (once for each of <code>foo</code>, <code>bar</code>, <code>baz</code>)?</p>
  
  <p><strong>What I mean is <em>not</em> a way to rewrite the above code to handle all 3 fields, but telling spark to process all 3 pipelines in a single pass.</strong></p>