list本地文件系统

bfrts1fy  于 2021-05-27  发布在  Spark
关注(0)|答案(0)|浏览(260)

我有在hdfs目录中列出文件的功能。我想在我的单元测试中列出本地目录文件,那么如何将配置切换到本地文件系统?我现在在测试中是这样使用它的:

val filesClient = new MockFilesClient(spark().sparkContext.hadoopConfiguration) //parameter i need to replace
filesClient.list(any[String]) returns List(samplePath)

方法本身:

class MockFilesClient(localFsConfig: Configuration){

  def list(path: String): List[String] = {
    listPath(new Path(path.toString), recursive = true)(localFsConfig)
      .toList
  }.map(p => p.toString)
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题