3
votes

I faced this weird problem while writing a mapreduce job for Hbase in Scala. The problem is that my scala class lets say ScalaMapReducer has to extends the following class http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableMapper.html

But when i do so and 'override' the map method (inherited form superclass Mapper of TableMapper), scala complains with error 'map overrides nothing' and fails to compile, while i can do so without any problems in Java.

I found the following workarounds:

1) Define a Dummy Java class which extends the TableMapper class and override the map with some empty implementation. And now from scala extend this Dummy class.

2) I found this on goole workaround which defines a Mappers trait.

ALthough i am guessing this may have something to do with Inner classes but i dont really have any more clue and explaination.

(This is intended to be a general Scala question)

EDIT: Sample Code from my scala class,

class ScalaMapReducer extends TableMapper[Text,IntWritable]
{
    override def map(row:ImmutableBytesWritable,result:Result,context:Context):Unit  =
    {
        //..some code
    }
}
2
Could you please add some example code that illustrates the error? - drexin

2 Answers

4
votes

The error map overrides nothing is almost always because of the mismatch in key, value type in the map and reduce definitions. Doubly check that, also some sample code might help in better debugging.

4
votes

The most likely error which you have made (and you have made one), based on the supplied information (i.e. no code!) is one of mis-using a type parameter. For example, if the interface defines a method:

public interface I<T> { public void doStuff(T t); }

Perhaps you might have implemented as follows:

class I0 extends I[String] { override def doStuff[String](String s) }
                                               // ^^^^^^  ^^^^^^
                                               // oops, a type parameter

Although I cannot be sure because you have not shown us the code. If you are using an IDE, why not ask it to fill in a blank implementation? (using IDEA, this is CTRL-i)