How can I read all files from a directory on HDFS and process it using scalding. For the local filesystem I use the below
import com.twitter.scalding._
import com.twitter.scalding.JsonLine
import java.io._
class ParseJsonJob(args: Args) extends Job(args) {
val fileList = new File(args("input")).listFiles
val fields = ('device_guid
,'service_name
,'event_type
)
fileList.map {
fileName =>
JsonLine(fileName.toString, fields)
.read
.filter ('service_name) { name: String => name == "myservice" }
.write(Tsv(args("output") + fileName.toString.split("/").last))
}
}
That won't work with HDFS. Does TextLine or JsonLine read directories in addition to files?