Apache spark python两个数据帧rdd映射未并行执行

Apache spark python两个数据帧rdd映射未并行执行,python,apache-spark,hadoop,pyspark,apache-spark-sql,Python,Apache Spark,Hadoop,Pyspark,Apache Spark Sql,我们有4000万份简历和100万个职位。 我们对这两个文档都使用dataframe,然后交叉连接这两个文档。 然后我们使用finaldata.rdd.map(lambda行:process_行(row)) 该函数占用的时间太长。它不是并行执行的 sc = SparkContext() collection_file = sc.textFile("hdfs://ip:port/user/Mongo_11July") sqlContext = SQLContext(sc) c

我们有4000万份简历和100万个职位。 我们对这两个文档都使用dataframe,然后交叉连接这两个文档。 然后我们使用finaldata.rdd.map(lambda行:process_行(row)) 该函数占用的时间太长。它不是并行执行的

sc = SparkContext()
    collection_file = sc.textFile("hdfs://ip:port/user/Mongo_11July")
    sqlContext = SQLContext(sc)
    collection_df = sqlContext.read.json(collection_file)
    collection_df.createOrReplaceTempView("temp1")


    jobtitle_file = sc.textFile("hdfs://ip:port/user/Jobtitle_11July")


    jobtitle_df = sqlContext.read.json(jobtitle_file)
    jobtitle_df.createOrReplaceTempView("jobtitle")



    df_cases = sqlContext.sql("SELECT _id,HTMLtext FROM temp1 ")
    df_job_titles = sqlContext.sql("SELECT distinct(Name) FROM jobtitle")



    schema = StructType([
        StructField("_id", StructType([StructField("$oid",StringType(),True)]), True),
        StructField("HTMLtext", StringType(), True),
        StructField("Name", StringType(), True),
        StructField("Tags_Add", ArrayType(StringType()), True)])   

    finaldata = df_cases.crossJoin(df_job_titles) 
    new_rdd = finaldata.rdd.map(lambda row: process_row(row)) 
    new_df = sqlContext.createDataFrame(new_rdd,schema) 
    final_new_df = new_df.groupBy("_id").agg(collect_list("Tags_Add").alias("Tags_Add"))
    flattenUdf = F.udf(fudf, ArrayType(StringType()))
    outputdataframe=final_new_df.select("_id", flattenUdf("Tags_Add").alias("Tags_Add"))

您是在多节点集群上执行,还是在本地执行模式下执行?另外,你能分享一下你对你的
process\u row()
功能的见解吗?如果它是python本机操作,则应该限制为顺序执行,因为它本质上受到python的单线程属性的限制。在进程行中,我们编写了自定义代码来查找文档中word的xpath。使用第三方库。您是否尝试更改HDFS文件的复制大小?根据您的总文件大小,这可能有助于整个过程。但是,除非您设法“并行化”您的进程_row()函数,否则我担心这里不会有太多的速度提升。。。