rdd.mapPartitions{ partition =>
if (!partition.isEmpty) {
// Some setup code here
partition.map(item => {
val output =yourfunction(item)
if (!partition.hasNext){
// Some cleanup code here
}
output
})
} else {
// return an empty Iterator of your return type
}
}

 

mapPartitions IO等资源管理

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-09-25
猜你喜欢
  • 2022-12-23
  • 2021-12-07
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
相关资源
相似解决方案