title: More than expected jobs running in apache spark
body: <p>I am trying to learn apache-spark. This is my code which i am trying to run. I am using <code>pyspark api</code>. </p>
  
  <pre><code>data = xrange(1, 10000)
  xrangeRDD = sc.parallelize(data, 8)
  def ten(value):
    """Return whether value is below ten.
  
    Args:
        value (int): A number.
  
    Returns:
        bool: Whether `value` is less than ten.
    """
    if (value &lt; 10):
        return True
    else:
        return False
  filtered = xrangeRDD.filter(ten)
  
  print filtered.collect()
  print filtered.take(8)
  </code></pre>
  
  <p><code>print filtered.collect()</code> gives this as output <code>[1, 2, 3, 4, 5, 6, 7, 8, 9]</code>. </p>
  
  <p>As per my understanding <code>filtered.take(n)</code> will take n elements from RDD and print it. </p>
  
  <p>I am trying two cases :- </p>
  
  <p>1)Giving value of n less than or equal to number of elements in RDD</p>
  
  <p>2)Giving value of n greater than number of elements in RDD</p>
  
  <p>I have <code>pyspark application UI</code> to see number of jobs that run in each case. In first case only <code>one job</code> is running but in second <code>five jobs</code> are running. </p>
  
  <p>I am not able to understand why is this happening.  Thanks in advance. </p>