Scala和Spark:createStream时出错

时间:2016-04-14 15:51:58

标签: scala spark-streaming

错误时:使用Scala和Twitter4j在Spark中创建推文流。 以下是我的代码片段:

scala> val ssc = new StreamingContext(sc, Seconds(10))
scala> val cb = new ConfigurationBuilder
scala>cb.setDebugEnabled(true).setOAuthConsumerKey("**********").setOAuthConsume
scala> val auth = new OAuthAuthorization(cb.build)
scala> val tweets = TwitterUtils.createStream(ssc,auth)
  

错误:重载方法值createStream with   备择方案:            (jssc:org.apache.spaark.streaming.api.java.JavaStreamingContext,twitterAuth:twitter4j.auth.Authorization)   org.apache.spark.streaming.api.java.JavaReceiverInputDStream [twitter4j.Status]    (JSSC:org.apache.spark.streaming.api.java.JavaStreamingContext,   过滤器:   阵列[字符串])org.apache.spark.streaming.api.java.JavaReceiverInputDStream [twitter4j.Status]    (SSC:org.apache.spark.streaming.StreamingContext,twitterAuth:   选项[twitter4j.auth.Authorization],过滤器:   SEQ [字符串],storageLevel:   org.apache.spark.storage.StorageLevel)org.apache.spark.streaming.dstream.ReceiverInputDStream [twitter4j.Status]   无法应用于(org.apache.spark.streaming.StreamingContext,   twitter4j.auth.OAuthAuthorization)

1 个答案:

答案 0 :(得分:2)

您使用expects a StreamingContext and an Option[Authorization]而不是Authorization的超载。

这应该有效:

val tweets = TwitterUtils.createStream(ssc, Some(auth))