I have written a MapReduce program, code is below:
import java.io.IOException;
import java.util.Iterator;
import org.apache.hadoop.io.IntWritable;
import org
Your mapper and reducer classes need to be defined static, otherwise the compile creates a constructor with a single argument (the parent MaxTemperature
class). Hence there now is not a default constructor.
public static class MaxTemperatureMapper extends Mapper<....
public static class MaxTemperatureReducer extends Reducer<....
I fixed Similar error in scala
with default constructor in my custom KEY
from Mapper
for Reducer
15/05/12 01:07:57 WARN mapred.LocalJobRunner: job_local1713686765_0001
java.lang.Exception: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :java.lang.NoSuchMethodException: IntPair.<init>()
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
Caused by: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :java.lang.NoSuchMethodException: IntPair.<init>()
at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:414)
at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:698)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:243)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
class IntPair (first : IntWritable, second : IntWritable) extends WritableComparable[IntPair] {
def this() = this(first = new IntWritable(), second = new IntWritable())
def getFirst () : IntWritable = {
first
}
def getSecond () : IntWritable = {
second
}
}
I'm guessing that Mapper
does not have a default constructor, but that's the only constructor your MaxTemperatureMapper
has.