Scala mapreduce字数计算程序

Scala mapreduce字数计算程序,scala,hadoop,mapreduce,Scala,Hadoop,Mapreduce,我写了这个scala程序来计算字数。下面给出了主要类 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: wordco

我写了这个scala程序来计算字数。下面给出了主要类

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{
def main(args:Array[String]):Int={
val conf=新配置()
val otherArgs=new genericonptionsparser(conf,args).getRemainingArgs
if(otherArgs.length!=2){
println(“用法:字数”)
返回2
}
val作业=新作业(配置,“字数”)
job.setJarByClass(类[TokenizerMapper])
job.setMapperClass(类[TokenizerMapper])
job.setCombinerClass(类[IntSumReducer])
job.setReducerClass(类[IntSumReducer])
job.setOutputKeyClass(classOf[Text])
job.setOutputValueClass(类[IntWritable])
FileInputFormat.addInputPath(作业,新路径(args(0)))
setOutputPath(作业,新路径((args(1)))
if(job.waitForCompletion(true))0其他1
}
}
我得到一个警告: “aaa有一个参数类型为Array[String]的主方法,但Hadooop.aaa将不是可运行的程序。原因:主方法必须具有精确的签名(Array[String])单元。”


如何解决这个问题?此外,我无法在RunConfiguration中加载此类。请帮我解决这个问题。

可能是因为您在声明main的地方使用了
:Int

尝试将main声明替换为

def main(args:Array[String]) : Unit = {
    //...
}
对于带有退出代码的每次返回,请根据具体情况调用
System.exit(1)
System.exit(0)


我确信您正在寻找一种更优雅的终止方式,但这应该是您想要的。

如果
main()
签名必须是“(数组[String])单位,则无法从中返回任何值。删除返回值[0,1和2]并查看会发生什么。删除并修复警告。但无法在RunConfiguration中加载此类。“但无法在RunConfiguration中加载此类”尝试时会发生什么?使用“搜索”按钮进行搜索时,运行配置中未列出主类。如果显式指定了完整路径,则“错误:无法找到或加载主类aaa.scala”。