Note that there are some explanatory texts on larger screens.

plurals
  1. POhadoop key returns multiple values
    primarykey
    data
    text
    <p>This is my first time programming in Hadoop and I'm basing my assignment off of WordCount v1.0 on the hadoop tutorial website.</p> <p>Assignment: You have two files. File0 contains every word in the dictionary. File1 contains one random word. For example: 'beautiful'.</p> <p>And when I run the program it should return every word in File0 that is the same size as the word in File1</p> <p>*beautiful will return every 9 letter word in the dictionary</p> <p>For example: beautiful - AARDVARKS AASVOGELS ABAMPERES....ZYMOGRAMS ZYMURGIES</p> <p>So my question is how should I go about this? The hadoop wordcount v1.0 returns the key and a single value. ---- e.g. (beautiful 4)</p> <p>Do I need to change the value from an int to a string or maybe some sort of an array that contains every word of the same size as the key?</p> <p>*basically I need to change the format from</p> <p>(beautiful 4)</p> <p>to</p> <p>(beautiful: AARDVARKS AASVOGELS ABAMPERES...ZYMOGENES ZYMOGRAMS ZYMURGIES)</p> <p>Here is the code (from their website):</p> <pre><code>package org.myorg; import java.io.IOException; import java.util.*; import org.apache.hadoop.fs.Path; import org.apache.hadoop.conf.*; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.*; import org.apache.hadoop.util.*; public class WordCount { public static class Map extends MapReduceBase implements Mapper&lt;LongWritable, Text, Text, IntWritable&gt; { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); public void map(LongWritable key, Text value, OutputCollector&lt;Text, IntWritable&gt; output, Reporter reporter) throws IOException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); output.collect(word, one); } } } public static class Reduce extends MapReduceBase implements Reducer&lt;Text, IntWritable, Text, IntWritable&gt; { public void reduce(Text key, Iterator&lt;IntWritable&gt; values, OutputCollector&lt;Text, IntWritable&gt; output, Reporter reporter) throws IOException { int sum = 0; while (values.hasNext()) { sum += values.next().get(); } output.collect(key, new IntWritable(sum)); } } public static void main(String[] args) throws Exception { JobConf conf = new JobConf(WordCount.class); conf.setJobName("wordcount"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(IntWritable.class); conf.setMapperClass(Map.class); conf.setCombinerClass(Reduce.class); conf.setReducerClass(Reduce.class); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(TextOutputFormat.class); FileInputFormat.setInputPaths(conf, new Path(args[0])); FileOutputFormat.setOutputPath(conf, new Path(args[1])); JobClient.runJob(conf); } } </code></pre> <p>Do I need to change the map, reduce, or both?? And how??</p> <p>can someone please help! thanks so much</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload