我在spark中使用mongo-hadoop客户端(r1.5.2)从mongoDB和bson中读取数据,请看以下链接:https://github.com/mongodb/mongo-hadoop/wiki/Spark-Usage。到目前为止,我可以从mongoDB读取没有问题。但是,bson配置甚至无法编译。请帮忙。Spark不能用mongo-hadoop连接器的BSONFileInputFormat编译newAPIHadoopRDD
我的代码在斯卡拉:
dataConfig.set("mapred.input.dir", "path.bson")
val documents = sc.newAPIHadoopRDD(
dataConfig,
classOf[BSONFileInputFormat],
classOf[Object],
classOf[BSONObject])
错误:
Error:(56, 24) inferred type arguments [Object,org.bson.BSONObject,com.mongodb.hadoop.mapred.BSONFileInputFormat] do not conform to method newAPIHadoopRDD's type parameter bounds [K,V,F <: org.apache.hadoop.mapreduce.InputFormat[K,V]]
val documents = sc.newAPIHadoopRDD(
^
尝试使用BSONFileInputFormat而不是MongoInputFormat。还请指定您正在使用的mongo-hadoop连接器的版本。 –