我有一个流媒体应用程序,当我尝试调用HiveContext.getOrCreate时,它会出现以下stmt错误。无法在包org.apache.spark.sql.hive中访问对象HiveContext包中的HiveContext '
对于我的应用程序,我需要HiveContext而不是SQLContext,并且每次创建新的HiveContext都不是一个可行的解决方案。
这是我的代码段:
object sampleStreamingApp {
def createStreamingContext(checkpointDirectory: String): StreamingContext = {
val conf = new SparkConf().setAppName("sampleStreaming")
val sc = new SparkContext(conf)
val ssc = new StreamingContext(sc, Milliseconds(5000))
ssc.checkpoint(checkpointDirectory)
val smDStream = ssc.textFileStream("/user/hdpuser/data")
val smSplitted = smDStream.map( x => x.split(";") ).map( x => Row.fromSeq( x ) )
smSplitted.foreachRDD { rdd =>
val sqlContext = HiveContext.getOrCreate(rdd.sparkContext)
import sqlContext.implicits._
<other code logic goes here>
}
}
ssc
}
def main(args: Array[String]) {
val checkpointDirectory = "hdfs://localhost:8020/user/dfml/checkpointing/AAA"
val ssc = StreamingContext.getActiveOrCreate(checkpointDirectory, () => createStreamingContext(checkpointDirectory))
ssc.start()
ssc.awaitTermination()
}
}
任何帮助将不胜感激
答案 0 :(得分:0)
对象HiveContext是私有的,因此无法访问。