Database Reference
In-Depth Information
}
else if
(
parser
.
isMissingTemperature
()) {
context
.
getCounter
(
Temperature
.
MISSING
).
increment
(
1
);
}
// dynamic counter
context
.
getCounter
(
"TemperatureQuality"
,
parser
.
getQuality
()).
increment
(
1
);
}
}
@Override
public
int
run
(
String
[]
args
)
throws
Exception
{
Job job
=
JobBuilder
.
parseInputAndOutput
(
this
,
getConf
(),
args
);
if
(
job
==
null
) {
return
-
1
;
}
job
.
setOutputKeyClass
(
Text
.
class
);
job
.
setOutputValueClass
(
IntWritable
.
class
);
job
.
setMapperClass
(
MaxTemperatureMapperWithCounters
.
class
);
job
.
setCombinerClass
(
MaxTemperatureReducer
.
class
);
job
.
setReducerClass
(
MaxTemperatureReducer
.
class
);
return
job
.
waitForCompletion
(
true
) ?
0
:
1
;
}
public static
void
main
(
String
[]
args
)
throws
Exception
{
int
exitCode
=
ToolRunner
.
run
(
new
MaxTemperatureWithCounters
(),
args
);
System
.
exit
(
exitCode
);
}
}
The best way to see what this program does is to run it over the complete dataset:
%
hadoop jar hadoop-examples.jar MaxTemperatureWithCounters \
input/ncdc/all output-counters
When the job has successfully completed, it prints out the counters at the end (this is done
by the job client). Here are the ones we are interested in:
Air Temperature Records
Malformed=3
Missing=66136856
TemperatureQuality
0=1