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

    https://github.com/apache/spark/pull/10385#discussion_r48310820
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/streaming/RecoverableNetworkWordCount.scala
 ---
    @@ -23,13 +23,55 @@ import java.nio.charset.Charset
     
     import com.google.common.io.Files
     
    -import org.apache.spark.SparkConf
    +import org.apache.spark.{Accumulator, SparkConf, SparkContext}
    +import org.apache.spark.broadcast.Broadcast
     import org.apache.spark.rdd.RDD
     import org.apache.spark.streaming.{Time, Seconds, StreamingContext}
     import org.apache.spark.util.IntParam
     
     /**
    - * Counts words in text encoded with UTF8 received from the network every 
second.
    + * Use this singleton to get or register `Broadcast`.
    + */
    +object WordBlacklist {
    +
    +  @volatile private var instance: Broadcast[Seq[String]] = null
    +
    +  def getInstance(sc: SparkContext): Broadcast[Seq[String]] = {
    +    if (instance == null) {
    +      synchronized {
    +        if (instance == null) {
    +          val wordBlacklist = Seq("a", "b", "c")
    +          instance = sc.broadcast(wordBlacklist)
    +        }
    +      }
    +    }
    +    instance
    +  }
    +}
    +
    +/**
    + * Use this singleton to get or register `Accumulator`.
    + */
    +object DroppedWordsCounter {
    +
    +  @volatile private var instance: Accumulator[Long] = null
    --- End diff --
    
    same comment as above.


---
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.
---

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

Reply via email to