我有一个流应用程序,当我尝试调用HiveContext.getOrCreate时,它会使用下面的stmt错误。“包单元中的对象HiveContext不能在包org.apache.spark.sql.hive中访问”
我的应用程序需要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()
}
}如能提供任何帮助,将不胜感激。
发布于 2016-11-15 09:46:18
对象HiveContext是私有的,因此它无法访问。
https://stackoverflow.com/questions/40604218
复制相似问题