apachespark—在pyspark中使用结构化流读取数据,并希望写入文件大小为100mb的数据

jvlzgdj9  于 2021-05-27  发布在  Spark
关注(0)|答案(1)|浏览(219)

希望你们都好。我正在使用结构化流媒体从目录中读取文件

schema = StructType([
    StructField("RowNo", StringType()),
    StructField("InvoiceNo", StringType()),
    StructField("StockCode", StringType()),
    StructField("Description", StringType()),
    StructField("Quantity", StringType()),
    StructField("InvoiceDate", StringType()),
    StructField("UnitPrice", StringType()),
    StructField("CustomerId", StringType()),
    StructField("Country", StringType()),
    StructField("InvoiceTimestamp", StringType())
])

data = spark.readStream.format("orc").schema(schema).option("header", "true").option("path", "<path_here>").load()

在应用一些转换之后,我喜欢保存大小为100mb的输出文件。

mlnl4t2r

mlnl4t2r1#

您应该覆盖默认的hdfs块大小。

block_size = str(1024 * 1024 * 100)

sc._jsc.hadoopConfiguration().set("dfs.block.size", block_size)

参考资料:如何在pyspark中更改hdfs块大小?

相关问题