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

    https://github.com/apache/spark/pull/10385#discussion_r48310785
  
    --- Diff: 
examples/src/main/java/org/apache/spark/examples/streaming/JavaRecoverableNetworkWordCount.java
 ---
    @@ -41,7 +46,48 @@
     import org.apache.spark.streaming.api.java.JavaStreamingContextFactory;
     
     /**
    - * Counts words in text encoded with UTF8 received from the network every 
second.
    + * Use this singleton to get or register `Broadcast`.
    + */
    +class JavaWordBlacklist {
    +
    +  private static volatile Broadcast<List<String>> instance = null;
    +
    +  public static Broadcast<List<String>> getInstance(JavaSparkContext jsc) {
    +    if (instance == null) {
    +      synchronized (WordBlacklist.class) {
    +        if (instance == null) {
    +          List<String> wordBlacklist = Arrays.asList("a", "b", "c");
    +          instance = jsc.broadcast(wordBlacklist);
    +        }
    +      }
    +    }
    +    return instance;
    +  }
    +}
    +
    +/**
    + * Use this singleton to get or register `Accumulator`.
    --- End diff --
    
    Similar comment as above for Broadcast.. "an accumulator"


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