From 36e991b6703491ad29e13aa6d08d4c3392007fa5 Mon Sep 17 00:00:00 2001 From: Nick Rushton Date: Mon, 12 Nov 2018 12:56:36 -0800 Subject: [PATCH] add case for when no records are present in the file * updated PAR1_END to \0PAR1, not all parquet files are written with \0\0PAR1 --- src/main/scala/ParquetDumper.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/scala/ParquetDumper.scala b/src/main/scala/ParquetDumper.scala index 98e818e..bba9ff3 100644 --- a/src/main/scala/ParquetDumper.scala +++ b/src/main/scala/ParquetDumper.scala @@ -76,7 +76,7 @@ class StdinUnpacker(printerActor: ActorRef) extends Actor with akka.actor.ActorL var numParOnes = 1 var sawParquetMrVersion = false val PAR1_BEG = scala.collection.mutable.Queue("PAR1".toList.map(_.toByte): _*) - val PAR1_END = scala.collection.mutable.Queue[Byte](0.toByte, 0.toByte) ++ PAR1_BEG + val PAR1_END = scala.collection.mutable.Queue[Byte](0.toByte) ++ PAR1_BEG var PARQUET_MR_VERSION = "parquet-mr version".toList.map(_.toByte).toVector val q = scala.collection.mutable.Queue[Byte]() @@ -168,6 +168,10 @@ class ParquetReaderActor(printerActor: ActorRef) extends Actor with akka.actor.A linesSent += 1 record = reader.read() } + // special case where the parquet file is empty + if (linesSent == 0) { + context.parent.tell(ParquetReaderFinished, self) + } new java.io.File(input).delete } }