title: How to use accumulator to count the records that have no matching items in leftOuterJoin?
body: <p>Spark <code>accumulators</code> are a great way to get useful information about an operation over an RDD.</p>
  
  <p>My problem is the following: I want to perform a join between two datasets, called, e.g. <code>events</code> and <code>items</code> (where the events are unique and involve items, and both are keyed by <code>item_id</code> which is primary for <code>items</code>)</p>
  
  <p>What works is this:</p>
  
  <pre><code>val joinedRDD = events.leftOuterJoin(items)
  </code></pre>
  
  <p>One possible way to know how many events did not have matching items is to write:</p>
  
  <pre><code>val numMissingItems = joinedRDD.map(x =&gt; if (x._2._2.isDefined) 0 else 1).sum
  </code></pre>
  
  <p>My question is: is there a way to obtain this count with an accumulator? I dont want to go through the RDD just to do the count. </p>