Task 1 MapReduce Dataset: A CSV dataset containing 1710671 taxi trajectories recorded…
- User
Task 1 MapReduce Dataset: A CSV dataset containing 1710671 taxi trajectories recorded over one year (from 2013/07/01 to 2014/06/30) in the city of Porto, in Portugal. The dataset is derived from the "Taxi Service Trajectory - Prediction Challenge, ECML PKDD 2015” Data Set. Each CSV row contains: • taxi_id: numeric value identifying an involved taxi. • trajectory_id: numeric value identifying a trajectory in the original dataset . • timestamp: a timestamp corresponding to the starting time of the taxi ride. • source_point: GPS point representing the origin of the taxi ride. • target_point: GPS point representing the destination of the taxi ride. Coordinates are given in POINT (longitude latitude) format using the EPSG:4326 Geodetic coordinate system. Source: https://figshare.com/articles/dataset/Porto_taxi_trajectories/12302165 Task: • Based on the source_point, calculate the count the number of taxi_id per source_point. • Expected output (Lat,Long), Count • The output should be ordered in ascending order according to the number of taxis per source points. taxi_id trajectory_id timestamp source_point target_point 20000589 1.37264E+18 7/1/2013 0:00 POINT(-8.618643 41.141412) POINT(-8.630838 41.154489) 20000596 1.37264E+18 7/1/2013 0:08 POINT(-8.639847 41.159826) POINT(-8.66574 41.170671) 20000320 1.37264E+18 7/1/2013 0:02 POINT(-8.612964 41.140359) POINT(-8.61597 41.14053) 20000520 1.37264E+18 7/1/2013 0:00 POINT(-8.574678 41.151951) POINT(-8.607996 41.142915) 20000337 1.37264E+18 7/1/2013 0:04 POINT(-8.645994 41.18049) POINT(-8.687268 41.178087) and this is sample of date .. pls provide me with the full code with java using cloudera vm
- Assistant
package org.myorg; import java.io.IOException; import java.util.StringTokenizer; 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.NullWritable; 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.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; public class TaxiCountPerSourcePoint { public static class TaxiMapper extends Mapper<LongWritable, Text, Text, IntWritable>{ private Text sourcePoint = new Text(); private final static IntWritable one = new IntWritable(1); public void map(LongWritable key, Text value, Context context ) throws IOException, InterruptedException { if (key.get() > 0) { String[] tokens = value.toString().split(","); if (tokens.length >= 4) { sourcePoint.set(tokens[3]); context.write(sourcePoint, one); } } } } public static class TaxiReducer extends Reducer<Text,IntWritable,Text,IntWritable> { private IntWritable result = new IntWritable(); public void reduce(Text key, Iterable<IntWritable> values, Context context ) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } result.set(sum); context.write(key, result); } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = Job.getInstance(conf, "taxi count per source point"); job.setJarByClass(TaxiCountPerSourcePoint.class); job.setMapperClass(TaxiMapper.class); job.setCombinerClass(TaxiReducer.class); job.setReducerClass(TaxiReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); } } - User
Task: • Based on the source_point, calculate the count the number of taxi_id per source_point. • Expected output (Lat,Long), Count • The output should be ordered in ascending order according to the number of taxis per source points. taxi_id trajectory_id timestamp source_point target_point 20000589 1.37264E+18 7/1/2013 0:00 POINT(-8.618643 41.141412) POINT(-8.630838 41.154489) 20000596 1.37264E+18 7/1/2013 0:08 POINT(-8.639847 41.159826) POINT(-8.66574 41.170671) 20000320 1.37264E+18 7/1/2013 0:02 POINT(-8.612964 41.140359) POINT(-8.61597 41.14053) 20000520 1.37264E+18 7/1/2013 0:00 POINT(-8.574678 41.151951) POINT(-8.607996 41.142915) 20000337 1.37264E+18 7/1/2013 0:04 POINT(-8.645994 41.18049) POINT(-8.687268 41.178087) pls write custom writable to this dataset with Partitioner class and socendry sort
- Assistant
- User
job.setSortComparatorClass(SourcePointSortComparator.class); error here
- Assistant
- User
i have map reduce task using java on cloudera vm on dataset taxi_id trajectory_id timestamp source_point target_point 20000589 1.37264E+18 7/1/2013 0:00 POINT(-8.618643 41.141412) POINT(-8.630838 41.154489) 20000596 1.37264E+18 7/1/2013 0:08 POINT(-8.639847 41.159826) POINT(-8.66574 41.170671) 20000320 1.37264E+18 7/1/2013 0:02 POINT(-8.612964 41.140359) POINT(-8.61597 41.14053) 20000520 1.37264E+18 7/1/2013 0:00 POINT(-8.574678 41.151951) POINT(-8.607996 41.142915).......• taxi_id: numeric value identifying an involved taxi. • trajectory_id: numeric value identifying a trajectory in the original dataset . • timestamp: a timestamp corresponding to the starting time of the taxi ride. • source_point: GPS point representing the origin of the taxi ride. • target_point: GPS point representing the destination of the taxi ride. Coordinates are given in POINT (longitude latitude) format using the EPSG:4326 Geodetic coordinate system..Task: • Based on the source_point, calculate the count the number of taxi_id per source_point. • Expected output (Lat,Long), Count • The output should be ordered in ascending order according to the number of taxis per source points.
- Assistant
- User
Based on the source_point, calculate the count the number of taxi_id per source_point. • Expected output (Lat,Long), Count • The output should be ordered in ascending order according to the number of taxis per source points.
- Assistant
I apologize for the confusion in my previous response. To include sorting the output in ascending order according to the number of taxis per source points, you will need to use the custom writable, partitioner, and secondary sorting that we have already implemented.
You can just use the custom
TaxiInfoWritable,TaxiPartitioner, andSourcePointSortComparatorclasses provided along with the updatedTaxiCountPerSourcePoint.javafile in one of my previous responses.You can directly use that code and follow the same steps mentioned earlier to upload the dataset to HDFS, compile and run the MapReduce job on the Cloudera VM.
Here is the link to my previous response with the Java code for your task: Code with custom writable, partitioner and secondary sort
- User
i need the full code with this specification pls
- Assistant