import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
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.util.Tool;
import org.apache.hadoop.util.ToolRunner;

import java.io.IOException;
import java.util.StringTokenizer;

// >>> Don't Change
public class OrphanPages extends Configured implements Tool {

    public static void main(String[] args) throws Exception {
        int res = ToolRunner.run(new Configuration(), new OrphanPages(), args);
        System.exit(res);
    }
// <<< Don't Change

    @Override
    public int run(String[] args) throws Exception {
        //TODO
    }

    public static class LinkCountMap extends Mapper<Object, Text, IntWritable, IntWritable> {
        @Override
        public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
            //TODO
        }
    }

    public static class OrphanPageReduce extends Reducer<IntWritable, IntWritable, IntWritable, NullWritable> {
        @Override
        public void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
            //TODO
        }
    }
}
@@ -994,249 +994,1467 @@
     
-%7D%0A%0A    public static class LinkCountMap extends Mapper%3CObject, Text, IntWritable, IntWritable%3E %7B%0A        @Override%0A        public void map(Object key, Text value, Context context) throws IOException, InterruptedException %7B%0A            //TODO
+    Job job = Job.getInstance(this.getConf(), %22Orphan Pages%22);%0A        job.setOutputKeyClass(IntWritable.class);%0A        job.setOutputValueClass(IntWritable.class);%0A%0A        job.setMapOutputKeyClass(IntWritable.class);%0A        job.setMapOutputValueClass(IntWritable.class);%0A%0A        job.setMapperClass(LinkCountMap.class);%0A        job.setReducerClass(OrphanPageReduce.class);%0A%0A        FileInputFormat.setInputPaths(job, new Path(args%5B0%5D));%0A        FileOutputFormat.setOutputPath(job, new Path(args%5B1%5D));%0A%0A        job.setJarByClass(OrphanPages.class);%0A        return job.waitForCompletion(true) ? 0 : 1;%0A    %7D%0A%0A    public static class LinkCountMap extends Mapper%3CObject, Text, IntWritable, IntWritable%3E %7B%0A        @Override%0A        public void map(Object key, Text value, Context context) throws IOException, InterruptedException %7B%0A            //TODO%0A            String line = value.toString();%0A            StringTokenizer tokenizer = new StringTokenizer(line, %22 %5Ct,;.?!-:@%5B%5D()%7B%7D_*/%22);%0A%0A            Integer counter = 0;%0A%0A            while (tokenizer.hasMoreTokens()) %7B%0A                counter = counter + 1;%0A                String nextToken = tokenizer.nextToken();%0A%0A                if (counter == 1) %7B%0A                    context.write(new IntWritable(Integer.parseInt(nextToken)), new IntWritable(0));%0A                %7D else %7B%0A                    context.write(new IntWritable(Integer.parseInt(nextToken)), new IntWritable(1));%0A                %7D%0A            %7D
 %0A   
@@ -2742,32 +2742,249 @@
          //TODO%0A
+            int sum = 0;%0A            for (IntWritable val : values) %7B%0A                sum += val.get();%0A            %7D%0A%0A            if (sum == 0) %7B%0A                context.write(key, NullWritable.get());%0A            %7D%0A
         %7D%0A    %7D%0A

Create a list of orphan pages