title: Update broadcast variable in a RDD
body: <p>I have this RDD that i've broadcasted.</p>
  
  <pre><code>test = sc.parallelize([(1),(2),(3),(4)]).zipWithIndex().map(lambda x: (x[1],x[0]))
  return :
  {0: 1, 1: 2, 2: 3, 3: 4}
  </code></pre>
  
  <p>I have another RDD which is a list of tuple :</p>
  
  <pre><code>tuples=sc.parallelize([(0,1),(1,2),(3,2)])
  </code></pre>
  
  <p>My goal is to use the tuple as keys for my broadcast variable and update their values by one</p>
  
  <p>So for the tuple (0,1) my new broadcast variable will be. </p>
  
  <pre><code>{0: 2, 1: 3, 2: 3, 3: 4}
  </code></pre>
  
  <p>for the tuple (1,2)</p>
  
  <pre><code>{0: 2, 1: 4, 2: 4, 3: 4}
  </code></pre>
  
  <p>for the tuple (3,2)</p>
  
  <pre><code>{0: 2, 1: 4, 2: 5, 3: 5}
  </code></pre>
  
  <p>And return the last update broadcasted variable <code>{0: 2, 1: 4, 2: 5, 3: 5}</code></p>
  
  <p>I tried to code it but my results are not good, for each tuples it's increased by one but doesn't take into consideration the last results. </p>
  
  <pre><code>def modify_broadcast(j,test):
    main=j[0]
    context=j[1]
    test.value[main]=test.value[main]+1
    test.value[context]=test.value[context]+1
    return test.value
  
  test = sc.parallelize([(1),(2),(3),(4)]).zipWithIndex().map(lambda x: (x[1],x[0]))
  test = sc.broadcast(test.collectAsMap())
  
  
  print(test.value[0])
  coocurence = sc.parallelize([(0,1),(1,2),(3,2)]).map(lambda x: modify_broadcast(x,test))
  </code></pre>