我需要从多个不是父目录或子目录的路径中读取镶木地板文件.
例如,
dir1 ---
|
------- dir1_1
|
------- dir1_2
dir2 ---
|
------- dir2_1
|
------- dir2_2
Run Code Online (Sandbox Code Playgroud)
sqlContext.read.parquet(dir1) 从dir1_1和dir1_2读取镶木地板文件
现在我正在阅读每个目录并使用"unionAll"合并数据帧.有没有办法从dir1_2和dir2_1读取镶木地板文件而不使用unionAll或有任何花哨的方式使用unionAll
谢谢
所以,我有一个如下数据,
[ (1, data1), (1, data2), (2, data3), (1, data4), (2, data5) ]
Run Code Online (Sandbox Code Playgroud)
我想将其转换为以下内容,以便进一步处理.
[ (1, [data1, data2, data4]), (2, [data3, data5]) ]
Run Code Online (Sandbox Code Playgroud)
我使用了groupByKey和reduceByKey,但由于数据量非常大而失败.数据不高但宽.换句话说,键从1到10000,但是,值列表的范围从100k到900k.
我正在努力解决这个问题并计划申请mapPartitions或(Hash)partitioner.
所以,如果其中一个可行,我想知道
mapPartions,你能不能给一些代码片段?(Hash)partitioner,你能举一些例子来说明如何通过键之类的元素来控制分区.例如,有没有办法根据键创建每个分区(即1,2,...以上)而不需要随机播放.Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: ShuffleMapStage 9 (flatMap at TSUMLR.scala:209) has failed the maximum allowable number of times: 4. Most recent failure reason: org.apache.spark.shuffle.MetadataFetchFailedException: Missing an output location for shuffle 1
at org.apache.spark.MapOutputTracker$$anonfun$org$apache$spark$MapOutputTracker$$convertMapStatuses$2.apply(MapOutputTracker.scala:542)
at org.apache.spark.MapOutputTracker$$anonfun$org$apache$spark$MapOutputTracker$$convertMapStatuses$2.apply(MapOutputTracker.scala:538)
at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772)
at …Run Code Online (Sandbox Code Playgroud)