title: Converting Spark-kafka InputDStream to Array[Bytes]
body: <p>I am using scala &amp; consuming data from Kafka using below Spark Streaming approach:</p>
  
  <pre><code>val lines = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc, kafkaParams, topics).map(_._2)
  </code></pre>
  
  <p>Above variable returns InputDStream through which I am able to see data in raw/binary format using below code:
  println(line)</p>
  
  <p>But I need to apply avro format(schema available) on raw/binary format in order to see data in expected json format. In order to apply avro format, I need to to convert above InputDStream to Array[Bytes] which is used by avro.</p>
  
  <p>Can someone please let me know convert InputDStream to Array[Bytes]?</p>
  
  <p>Or </p>
  
  <p>If you know some better way to apply avro schema on InputDStream(of spark Streaming), please share.</p>