title: Extracting values from Scala WrappedArray
body: <p>I'm working with Apache Spark's ALS model, and the recommendForAllUsers method returns a dataframe with the schema</p>
  
  <pre><code>root
   |-- user_id: integer (nullable = false)
   |-- recommendations: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- item_id: integer (nullable = true)
   |    |    |-- rating: float (nullable = true)
  </code></pre>
  
  <p>In practice, the recommendations are a WrappedArray like:</p>
  
  <p><code>WrappedArray([636958,0.32910484], [995322,0.31974298], [1102140,0.30444127], [1160820,0.27908015], [1208899,0.26943958])</code></p>
  
  <p>I'm trying to extract <em>just</em> the item_ids and return them as a 1D array. So the above example would be <code>[636958,995322,1102140,1160820,1208899]</code></p>
  
  <p>This is what's giving me trouble. So far I have:</p>
  
  <pre><code>    val numberOfRecs = 20
      val userRecs = model.recommendForAllUsers(numberOfRecs).cache()
  
      val strippedScores = userRecs.rdd.map(row =&gt; {
        val user_id = row.getInt(0)
        val recs = row.getAs[Seq[Row]](1)
  
        val item_ids = new Array[Int](numberOfRecs)
  
        recs.toArray.foreach(x =&gt; {
          item_ids :+ x.get(0)
        })
  
        item_ids
      })
  </code></pre>
  
  <p>But this just returns <code>[I@2f318251</code>, and if I get the string value of it via mkString(","), it returns <code>0,0,0,0,0,0</code></p>
  
  <p>Any thoughts on how I can extract the item_ids and return them as a separate, 1D array?</p>