如何在Spark中解压缩和读取包含多个压缩文件的文件

时间:2018-11-20 08:46:16

标签: scala apache-spark bigdata

我有一个文件AA.zip,其中又包含多个文件,例如aa.tar.gz,bb.tar.gz等

我需要在spark scala中读取此文件,如何实现?

这里唯一的问题是提取zip文件的内容。

1 个答案:

答案 0 :(得分:0)

因此HDFS上的ZIP会有些棘手,因为它们分割得不好,因此每个执行者必须处理1个或多个zip文件。这也是少数情况下,您可能不得不退回到select st_id, st_date, st_sl, income_amount, util_date, util_amount from income i, util u where i.st_id = u.st_id and i.st_date = u.st_date and i.st_sl = u.st_sl; 的情况之一,因为某些原因,Spark中对二进制文件的支持并不那么好。

https://spark.apache.org/docs/2.4.0/api/scala/index.html#org.apache.spark.SparkContext

那里有一个SparkContext,可让您访问zip二进制数据,然后可以将其与Java或scala中的常规ZIP处理一起使用。

相关问题