私は Definitive Guide book から Hadoop を勉強していて、このコードを実行しようとしたところ、エラーが発生しました。
第 5 章の例。Github コードへのリンク:
ソース:
https://github.com/tomwhite/hadoop-book/blob/master/ch05/src/main/java/v1/MaxTemperatureMapper.java
public class MaxTemperatureMapper
extends Mapper<LongWritable, Text, Text, IntWritable> {
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String line = value.toString();
String year = line.substring(15, 19);
int airTemperature = Integer.parseInt(line.substring(87, 92));
context.write(new Text(year), new IntWritable(airTemperature));
}
}
public class MaxTemperatureMapperTest {
@Test
public void processesValidRecord() throws IOException, InterruptedException {
Text value = new Text("0043011990999991950051518004+68750+023550FM-12+0382" +
"99999V0203201N00261220001CN9999999N9-00111+99999999999");
new MapDriver<LongWritable, Text, Text, IntWritable>()
.withMapper(new MaxTemperatureMapper())
.withInputValue(value)
.withOutput(new Text("1950"), new IntWritable(-11))
.runTest();
}
私が得ているエラーは次のとおりです。
java.lang.IllegalStateException: No input was provided
at org.apache.hadoop.mrunit.MapDriverBase.preRunChecks(MapDriverBase.java:286)
at org.apache.hadoop.mrunit.mapreduce.MapDriver.run(MapDriver.java:142)
at org.apache.hadoop.mrunit.TestDriver.runTest(TestDriver.java:640)
at org.apache.hadoop.mrunit.TestDriver.runTest(TestDriver.java:627)
at book.hadoopdefinitiveguide.chap5.examples.MaxTemperatureMapperTest.processesValidRecord(MaxTemperatureMapperTest.java:12)
これはたまたま Hadoop で実行している最初のコードであり、このエラーがスローされています。どんな助けでも大歓迎です。前もって感謝します