Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-18035

Introduce performant and memory efficient APIs to create ArrayBasedMapData

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.1
    • 2.1.0
    • SQL
    • None

    Description

      In HiveInspectors, I saw that converting Java map to Spark's `ArrayBasedMapData` spent quite sometime in buffer copying : https://github.com/apache/spark/blob/master/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala#L658

      The reason being `map.toSeq` allocates a new buffer and copies the map entries to it: https://github.com/scala/scala/blob/2.11.x/src/library/scala/collection/MapLike.scala#L323

      This copy is not needed as we get rid of it once we extract the key and value arrays.

      Here is the call trace:

      org.apache.spark.sql.hive.HiveInspectors$$anonfun$unwrapperFor$41.apply(HiveInspectors.scala:664)
      scala.collection.AbstractMap.toSeq(Map.scala:59)
      scala.collection.MapLike$class.toSeq(MapLike.scala:323)
      scala.collection.AbstractMap.toBuffer(Map.scala:59)
      scala.collection.MapLike$class.toBuffer(MapLike.scala:326)
      scala.collection.AbstractTraversable.copyToBuffer(Traversable.scala:104)
      scala.collection.TraversableOnce$class.copyToBuffer(TraversableOnce.scala:275)
      scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:48)
      scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:104)
      scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
      scala.collection.AbstractIterable.foreach(Iterable.scala:54)
      scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
      scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
      scala.collection.Iterator$class.foreach(Iterator.scala:893)
      scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:59)
      scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:59)
      

      Attachments

        Activity

          People

            tejasp Tejas Patil
            tejasp Tejas Patil
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: