开发者

Refer to base types that have a raw type constraint

I've been playing around with Scala, trying to get SMR to compile in Scala IDE with 2.9.1. SMR seems to have gone untouched since 2008-ish, and there are a lot of unresolved compile errors. The one that I am getting stuck on is this line:

jobConf.setMapRunnerClass(classOf[ClosureMapper[_,_,_,_]]);

ClosureMapper is defined thus:

class ClosureMapper[K1,V1,K2,V2] extends MapRunnable[Writable,Writable,Writable,Writable] { 
  ...
}

and the error I get is:

type mismatch; 
found : java.lang.Class[smr.hadoop.ClosureMapper[_, _, _, _]](classOf[smr.hadoop.ClosureMapper]) 
required: java.lang.Class[_ <: org.apache.hadoop.mapred.MapRunnable]

So it looks to me like the JobConf class's setMapRunnerClass method is constraining the type parameter to inherit from MapRunnable (which ClosureMapper does), but more specifically MapRunnable's raw type, which Scala 开发者_开发知识库doesn't seem to appreciate.

I have tried the following, but got a different error:

jobConf.setMapRunnerClass(classOf[ClosureMapper]);

That one gives class ClosureMapper takes type parameters

Any ideas on how to get Scala to recognize the raw type constraint?


You might have to specify a bound for the type parameters of ClosureMapper:

jobConf.setMapRunnerClass(classOf[ClosureMapper[_ <: ClosureMapper[_],_ <: ClosureMapper[_],_ <: ClosureMapper[_],_ <: ClosureMapper[_]]]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜