Github user mateiz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/266#discussion_r11319296
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/util/RawTextHelper.scala ---
    @@ -19,40 +19,22 @@ package org.apache.spark.streaming.util
     
     import org.apache.spark.SparkContext
     import org.apache.spark.SparkContext._
    -import it.unimi.dsi.fastutil.objects.{Object2LongOpenHashMap => OLMap}
    +import org.apache.spark.util.collection.OpenHashMap
     import scala.collection.JavaConversions.mapAsScalaMap
     
     private[streaming]
     object RawTextHelper {
     
       /** 
    -   * Splits lines and counts the words in them using specialized 
object-to-long hashmap 
    -   * (to avoid boxing-unboxing overhead of Long in java/scala HashMap)
    +   * Splits lines and counts the words.
        */
       def splitAndCountPartitions(iter: Iterator[String]): Iterator[(String, 
Long)] = {
    -    val map = new OLMap[String]
    -    var i = 0
    -    var j = 0
    -    while (iter.hasNext) {
    -      val s = iter.next()
    -      i = 0
    -      while (i < s.length) {
    -        j = i
    -        while (j < s.length && s.charAt(j) != ' ') {
    -          j += 1
    -        }
    -        if (j > i) {
    -          val w = s.substring(i, j)
    -          val c = map.getLong(w)
    -          map.put(w, c + 1)
    -        }
    -        i = j
    -        while (i < s.length && s.charAt(i) == ' ') {
    -          i += 1
    -        }
    -      }
    +    val map = new OpenHashMap[String,Long]
    +    val tokenized = iter.flatMap(_.split(" ").filterNot(_.isEmpty))
    +    tokenized.foreach{ s =>
    +      map.changeValue(s, 1L, _ + 1L)
         }
    -    map.toIterator.map{case (k, v) => (k, v)}
    +    map.iterator
    --- End diff --
    
    Keep this code the way it was before, I think it was there for some stress 
tests that passed in lots of data, to make sure the parsing is not the 
bottleneck. Just switch the map over.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to