I am using Spark Streaming + Kafka for data ingestion into HDFS.
val ssc = new StreamingContext(sparkContext, Seconds(30))
val messageRecBased = KafkaUtils.createStream(ssc, zkQuorum, group, topic)
.map(_._2)
Each 30 sec all data in Kafka queue will be stored in a separate folder in HDFS. Some folders contains a empty file called part-00000 because there is no data in the corresponding batch-interval (30 sec). I used the following lines to filter those folders:
messageRecBased.filter { x => x.size == 0 }
messageRecBased.repartition(1).saveAsTextFiles("PATH")
but it is not working and it still generates folders with empty file.