Practical 5
Practical 5
Practical 5:
Aim:
Steps:
1. Open Eclipse IDE and create a new project with a class files – MovieRating.java
Open MovieRating.java and paste the following code:
MatrixRating.java
package Movie;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
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.*;
import org.apache.hadoop.mapreduce.lib.output.*;
{
IntWritable keyUserID = new
IntWritable(Integer.parseInt(valueStr.substring(0, index)));
context.write(keyUserID, new Text(valueStr.substring(index
+ 1)));
}
catch(Exception e)
{
// You could get a NumberFormatException
}
}
}
}
job.setReducerClass(MovieRatingsReducer.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path("/MovieRating/Input/Movie.txt"));
FileOutputFormat.setOutputPath(job, new Path("/MovieRating/Output"));
System.exit(job.waitForCompletion(true) ? 0:1);
}
}
Output:
Business Intelligence & Big Data Analytics - 2 Darpan Naik – 60