I had made changes in the file but still nothing happens. Please help i am
beginner in this.
kmer.java is attached herewith.

On Wed, Jan 7, 2015 at 7:03 PM, Vandana kumari <kvandana1...@gmail.com>
wrote:

> yes, there is no compilation error. But thank you for finding mistakes, i
> will make the above changes and let you all know.
>
> On Wed, Jan 7, 2015 at 6:52 PM, Shahab Yunus <shahab.yu...@gmail.com>
> wrote:
>
>> Vandana,
>>
>> Also, in the code that you attached, I see 2 compilation errors. How is
>> it even compiling? Or am I missing something here?
>>
>> 1- The 'sum' is not declared in the Map class.
>> 2- The 'sum' in the Reduce class, when written to the context needs to be
>> IntWritable and not directly an int.
>>
>> Regards,
>> Shahab
>>
>> On Wed, Jan 7, 2015 at 8:18 AM, Shahab Yunus <shahab.yu...@gmail.com>
>> wrote:
>>
>>> First try:
>>>
>>> You should use @Override annotation before map and reduce methods so
>>> they are actually called.
>>>
>>> Like this:
>>> *@Override*
>>>  public void map(LongWritable k,Text v,Context con)throws
>>> IOException,InterruptedException
>>>
>>>         {...
>>>
>>> Do same for 'reduce' method.
>>>
>>> Regards,
>>> Shahab
>>>
>>> On Wed, Jan 7, 2015 at 7:58 AM, Vandana kumari <kvandana1...@gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Wed, Jan 7, 2015 at 4:16 PM, saurabh chhajed <schhajed....@gmail.com
>>>> > wrote:
>>>>
>>>>> Can you attach .java file instead of .class ?
>>>>>
>>>>> On Wed, Jan 7, 2015 at 4:04 PM, Vandana kumari <kvandana1...@gmail.com
>>>>> > wrote:
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I had written a kmer mapreduce program in java. There is no error in
>>>>>> the program and while running it creates an output directory in hadoop 
>>>>>> file
>>>>>> system but that directory is empty.
>>>>>> Please help to resolve this issue.
>>>>>> Input file(test.txt) and kmer.java is attached herewith.
>>>>>> --
>>>>>> Thanks and regards
>>>>>>   Vandana kumari
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> [image: --]
>>>>> Saurabh Chhajed
>>>>> [image: http://]saurzcode.in/
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Thanks and regards
>>>>   Vandana kumari
>>>>
>>>
>>>
>>
>
>
> --
> Thanks and regards
>   Vandana kumari
>



-- 
Thanks and regards
  Vandana kumari
import java.io.IOException;
//import java.util.StringTokenizer;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class kmer 

{  
    
    public static class  Map extends Mapper<LongWritable,Text,Text,IntWritable>

    {
        
    	@Override
        public void map(LongWritable k,Text v,Context con)throws IOException,InterruptedException
         
        {
            String line =v.toString();
			for(int i=0;i<(line.length()-1);i=i+2)
			{
				String  y = line.substring(i,2);
				con.write(new Text(y), new IntWritable(1));
			}   
        }
        
    }
	
	public static class Reduce extends Reducer<Text,IntWritable,Text,IntWritable>
    	{
		private IntWritable result = new IntWritable();
		@Override
       	 	public void reduce(Text y,Iterable<IntWritable> values,Context con)throws IOException,InterruptedException
        	{
            		int sum=0;
           		for (IntWritable val : values) 
			{
				sum += val.get();
			}
            	result.set(sum);
           	con.write(y, result);
            
       		}
        
   	}
	
	 public static void main(String[] args)throws IOException, InterruptedException, ClassNotFoundException
    {
        Configuration c = new Configuration();
        String[] files = new GenericOptionsParser(c,args).getRemainingArgs();
        Path p1 = new Path(files[0]);
        Path p2 =new Path(files[1]);
        Job j = Job.getInstance();
        j.setJarByClass(kmer.class);
        j.setMapperClass(Map.class);
        j.setReducerClass(Reduce.class);
        j.setOutputKeyClass(Text.class);
        j.setOutputValueClass(IntWritable.class);
        FileInputFormat.addInputPath(j,p1);
        FileOutputFormat.setOutputPath(j,p2);
        System.exit(j.waitForCompletion(true) ? 0:1);
        
    }
}

Reply via email to