Sequence file to Image in spark

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Sequence file to Image in spark

Selvam Raman
Hi All,

I am trying to convert sequence file to image in spark.

i found that when i was reading bytearrayinputstream from bytes it throws serialization exception. Any insight will be helpful.

scala> sc.sequenceFile[NullWritable,BytesWritable]("D:/seqImage").map(x => {ImageIO.write(ImageIO.read(newByteArrayInputStream(x._2.copyBytes())),"png",new File("D:/ima"))}).collect

2018-04-28 15:45:52 ERROR Executor:91 - Exception in task 0.0 in stage 8.0 (TID

14)

java.lang.IllegalArgumentException: image == null!

        at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown Sour

ce)

        at javax.imageio.ImageIO.getWriter(Unknown Source)

        at javax.imageio.ImageIO.write(Unknown Source)

        at $line117.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$anonfun$1.apply(<cons

ole>:31)

        at $line117.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$anonfun$1.apply(<cons

ole>:31)

        at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)

        at scala.collection.Iterator$class.foreach(Iterator.scala:893)

        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)

        at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:

59)

        at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:

104)

        at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:

48)

        at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:310)

        at scala.collection.AbstractIterator.to(Iterator.scala:1336)

        at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala

:302)

        at scala.collection.AbstractIterator.toBuffer(Iterator.scala:1336)

        at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:

289)

        at scala.collection.AbstractIterator.toArray(Iterator.scala:1336)

        at org.apache.spark.rdd.RDD$$anonfun$collect$1$$anonfun$12.apply(RDD.sca

la:939)

        at org.apache.spark.rdd.RDD$$anonfun$collect$1$$anonfun$12.apply(RDD.sca

la:939)

        at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.sc

ala:2067)

        at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.sc

ala:2067)

        at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)

        at org.apache.spark.scheduler.Task.run(Task.scala:109)

        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:345)

 

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

2018-04-28 15:45:52 WARN  TaskSetManager:66 - Lost task 0.0 in stage 8.0 (TID 14

, localhost, executor driver): java.lang.IllegalArgumentException: image == null

!

        at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown Sour

ce)



--
Selvam Raman
"லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"