You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/05 22:18:57 UTC

[GitHub] [spark] ueshin commented on a change in pull request #26512: [WIP][SPARK-29493][SQL] Arrow MapType support

ueshin commented on a change in pull request #26512: [WIP][SPARK-29493][SQL] Arrow MapType support
URL: https://github.com/apache/spark/pull/26512#discussion_r354576026
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/arrow/ArrowWriter.scala
 ##########
 @@ -343,3 +348,37 @@ private[arrow] class StructWriter(
     children.foreach(_.reset())
   }
 }
+
+private[arrow] class MapWriter(
+    val valueVector: MapVector,
+    val keyWriter: ArrowFieldWriter,
+    val valueWriter: ArrowFieldWriter) extends ArrowFieldWriter {
+
+  override def setNull(): Unit = {}
+
+  override def setValue(input: SpecializedGetters, ordinal: Int): Unit = {
+    val map = input.getMap(ordinal)
+    valueVector.startNewValue(count)
+    val keys = map.keyArray()
+    val values = map.valueArray()
+
+    for (i <- 0 until map.numElements()) {
+      keyWriter.write(keys, i)
+      valueWriter.write(values, i)
+    }
 
 Review comment:
   We might want to use `while` loop to be performant like `ArrayWriter`.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org