MAPREDUCE-6819. Replace UTF8 with Text in MRBench. Contributed by Peter Bacsko.
This commit is contained in:
parent
a9d946d4df
commit
7ee8be1aa3
@ -29,7 +29,6 @@
|
|||||||
import org.apache.hadoop.conf.Configured;
|
import org.apache.hadoop.conf.Configured;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.io.UTF8;
|
|
||||||
import org.apache.hadoop.io.WritableComparable;
|
import org.apache.hadoop.io.WritableComparable;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
@ -56,14 +55,14 @@ public static enum Order {RANDOM, ASCENDING, DESCENDING};
|
|||||||
* writes out data as text again.
|
* writes out data as text again.
|
||||||
*/
|
*/
|
||||||
public static class Map extends MapReduceBase
|
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,
|
public void map(WritableComparable<?> key, Text value,
|
||||||
OutputCollector<UTF8, UTF8> output,
|
OutputCollector<Text, Text> output,
|
||||||
Reporter reporter) throws IOException
|
Reporter reporter) throws IOException
|
||||||
{
|
{
|
||||||
String line = value.toString();
|
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) {
|
public String process(String line) {
|
||||||
return line;
|
return line;
|
||||||
@ -74,13 +73,14 @@ public String process(String line) {
|
|||||||
* Ignores the key and writes values to the output.
|
* Ignores the key and writes values to the output.
|
||||||
*/
|
*/
|
||||||
public static class Reduce extends MapReduceBase
|
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,
|
public void reduce(Text key, Iterator<Text> values,
|
||||||
OutputCollector<UTF8, UTF8> output, Reporter reporter) throws IOException
|
OutputCollector<Text, Text> output,
|
||||||
|
Reporter reporter) throws IOException
|
||||||
{
|
{
|
||||||
while(values.hasNext()) {
|
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.setInputFormat(TextInputFormat.class);
|
||||||
jobConf.setOutputFormat(TextOutputFormat.class);
|
jobConf.setOutputFormat(TextOutputFormat.class);
|
||||||
|
|
||||||
jobConf.setOutputValueClass(UTF8.class);
|
jobConf.setOutputValueClass(Text.class);
|
||||||
|
|
||||||
jobConf.setMapOutputKeyClass(UTF8.class);
|
jobConf.setMapOutputKeyClass(Text.class);
|
||||||
jobConf.setMapOutputValueClass(UTF8.class);
|
jobConf.setMapOutputValueClass(Text.class);
|
||||||
|
|
||||||
if (null != jarFile) {
|
if (null != jarFile) {
|
||||||
jobConf.setJar(jarFile);
|
jobConf.setJar(jarFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user