def collect(as_enum=false)
      file = Tempfile.new('collect', context.temp_dir)

      context.set_call_site(caller.first)
      RubyRDD.writeRDDToFile(jrdd.rdd, file.path)

      collect_from_file(file, as_enum)
    rescue => e
      raise Spark::RDDError, e.message
    ensure
      context.clear_call_site
    end
def collect(as_enum=false)
      file = Tempfile.new('collect', context.temp_dir)

      context.set_call_site(caller.first)
      RubyRDD.writeRDDToFile(jrdd.rdd, file.path)

      collect_from_file(file, as_enum)
    rescue => e
      raise Spark::RDDError, e.message
    ensure
      context.clear_call_site
    end
=============================================================================
 Actions which return value
 Return an array that contains all of the elements in this RDD.
 RJB raise an error if stage is killed.