MAPREDUCE-6819. Replace UTF8 with Text in MRBench. Contributed by Peter Bacsko.

This commit is contained in:
Akira Ajisaka 2017-01-17 17:56:10 +09:00
parent a9d946d4df
commit 7ee8be1aa3

View File

@ -29,7 +29,6 @@
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.UTF8;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.util.Tool;
@ -56,14 +55,14 @@ public static enum Order {RANDOM, ASCENDING, DESCENDING};
* writes out data as text again.
*/
public static class Map extends MapReduceBase
implements Mapper<WritableComparable, Text, UTF8, UTF8> {
implements Mapper<WritableComparable<?>, Text, Text, Text> {
public void map(WritableComparable key, Text value,
OutputCollector<UTF8, UTF8> output,
public void map(WritableComparable<?> key, Text value,
OutputCollector<Text, Text> output,
Reporter reporter) throws IOException
{
String line = value.toString();
output.collect(new UTF8(process(line)), new UTF8(""));
output.collect(new Text(process(line)), new Text(""));
}
public String process(String line) {
return line;
@ -74,13 +73,14 @@ public String process(String line) {
* Ignores the key and writes values to the output.
*/
public static class Reduce extends MapReduceBase
implements Reducer<UTF8, UTF8, UTF8, UTF8> {
implements Reducer<Text, Text, Text, Text> {
public void reduce(UTF8 key, Iterator<UTF8> values,
OutputCollector<UTF8, UTF8> output, Reporter reporter) throws IOException
public void reduce(Text key, Iterator<Text> values,
OutputCollector<Text, Text> output,
Reporter reporter) throws IOException
{
while(values.hasNext()) {
output.collect(key, new UTF8(values.next().toString()));
output.collect(key, new Text(values.next().toString()));
}
}
}
@ -151,10 +151,10 @@ private JobConf setupJob(int numMaps, int numReduces, String jarFile) {
jobConf.setInputFormat(TextInputFormat.class);
jobConf.setOutputFormat(TextOutputFormat.class);
jobConf.setOutputValueClass(UTF8.class);
jobConf.setOutputValueClass(Text.class);
jobConf.setMapOutputKeyClass(UTF8.class);
jobConf.setMapOutputValueClass(UTF8.class);
jobConf.setMapOutputKeyClass(Text.class);
jobConf.setMapOutputValueClass(Text.class);
if (null != jarFile) {
jobConf.setJar(jarFile);