Skip to content

Instantly share code, notes, and snippets.

@barik
Last active August 29, 2015 14:15
Show Gist options
  • Save barik/e22bbdca90b8610045bd to your computer and use it in GitHub Desktop.
Save barik/e22bbdca90b8610045bd to your computer and use it in GitHub Desktop.
package net.barik.spreadsheet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.NLineInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
public class WARCExtractJob extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.err.printf("Usage: %s [generic options] <input> <output>\n",
getClass().getSimpleName());
ToolRunner.printGenericCommandUsage(System.err);
return -1;
}
Configuration conf = getConf();
conf.set("mapreduce.input.lineinputformat.linespermap", "400");
Job job = new Job(conf);
job.setJarByClass(WARCExtractJob.class);
job.setInputFormatClass(NLineInputFormat.class);
job.setMapperClass(WARCExportMapper.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
NLineInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
return job.waitForCompletion(true) ? 0 : 1;
}
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new WARCExtractJob(), args);
System.exit(exitCode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment