0
我写这个scala程序为字数。和主类如下斯卡拉mapreduce WordCount程序
object aaa{
def main(args:Array[String]) : Int = {
val conf = new Configuration()
val otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs
if (otherArgs.length != 2) {
println("Usage: wordcount <in> <out>")
return 2
}
val job = new Job(conf, "word count")
job.setJarByClass(classOf[TokenizerMapper])
job.setMapperClass(classOf[TokenizerMapper])
job.setCombinerClass(classOf[IntSumReducer])
job.setReducerClass(classOf[IntSumReducer])
job.setOutputKeyClass(classOf[Text])
job.setOutputValueClass(classOf[IntWritable])
FileInputFormat.addInputPath(job, new Path(args(0)))
FileOutputFormat.setOutputPath(job, new Path((args(1))))
if (job.waitForCompletion(true)) 0 else 1
}
}
在这里,我得到一个警告给出: “AAA与参数类型数组[字符串]一个主要方法,但Hadooop.aaa不会是一个可运行的程序。原因:主要方法必须具有确切的签名(数组[String])单位“。
如何解决这个问题?另外我无法在RunConfiguration中加载这个类。请帮我解决这个问题。
如果'main()'签名必须是“(Array [String])Unit”,那么你不能从它返回任何值。删除你的返回值[0,1和2],看看会发生什么。 – jwvh
已移除并警告已修复。但不能在RunConfiguration中加载这个类。 –
“但是无法在RunConfiguratio中加载此类”尝试时会发生什么?不要让我们猜测 –