srowen commented on a change in pull request #22282: [SPARK-23539][SS] Add 
support for Kafka headers in Structured Streaming
URL: https://github.com/apache/spark/pull/22282#discussion_r247349322
 
 

 ##########
 File path: 
external/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala
 ##########
 @@ -258,17 +260,34 @@ class KafkaTestUtils(withBrokerProps: Map[String, 
Object] = Map.empty) extends L
       topic: String,
       messages: Array[String],
       partition: Option[Int]): Seq[(String, RecordMetadata)] = {
+    sendMessages(topic, messages.map(m => (m, Array[(String, 
Array[Byte])]())), partition)
+  }
+
+  /** Send record to the Kafka broker with headers using specified partition */
+  def sendMessage(topic: String,
+                  record: (String, Array[(String, Array[Byte])]),
+                  partition: Option[Int]): Seq[(String, RecordMetadata)] = {
+    sendMessages(topic, Array(record), partition)
+  }
+
+  /** Send the array of records to the Kafka broker with headers using 
specified partition */
+  def sendMessages(topic: String,
+                   records: Array[(String, Array[(String, Array[Byte])])],
+                   partition: Option[Int]): Seq[(String, RecordMetadata)] = {
     producer = new KafkaProducer[String, String](producerConfiguration)
     val offsets = try {
-      messages.map { m =>
+      records.map { r =>
         val record = partition match {
-          case Some(p) => new ProducerRecord[String, String](topic, p, null, m)
-          case None => new ProducerRecord[String, String](topic, m)
+          case Some(p) => new ProducerRecord[String, String](
 
 Review comment:
   The wrapping and code are a little hard to follow. Maybe introduce vals with 
intermediate values to clarify. Also maybe use `case (..., ...) =>` statements 
for tuples rather than `._1`, etc

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to