in emr-dynamodb-tools/src/main/java/org/apache/hadoop/dynamodb/tools/DynamoDBExport.java [46:98]
public int run(String[] args) throws Exception {
if (args.length < 2) {
printUsage("Not enough parameters");
return -1;
}
JobConf jobConf = new JobConf(getConf(), DynamoDBExport.class);
jobConf.setJobName("dynamodb-export");
jobConf.setOutputKeyClass(Text.class);
jobConf.setOutputValueClass(Text.class);
jobConf.setMapperClass(ExportMapper.class);
jobConf.setReducerClass(IdentityReducer.class);
jobConf.setInputFormat(DynamoDBInputFormat.class);
jobConf.setOutputFormat(ExportManifestOutputFormat.class);
jobConf.setNumReduceTasks(1);
Path outputPath = new Path(args[0]);
FileOutputFormat.setOutputPath(jobConf, outputPath);
String tableName = args[1];
Double readRatio = null;
if (args.length >= 3) {
String val = args[2];
try {
readRatio = Double.parseDouble(val);
} catch (Exception e) {
printUsage("Could not parse read ratio (value: " + val + ")");
return -1;
}
}
Integer totalSegments = null;
if (args.length >= 4) {
String val = args[3];
try {
totalSegments = Integer.parseInt(val);
} catch (Exception e) {
printUsage("Could not parse segment count (value: " + val + ")");
return -1;
}
}
setTableProperties(jobConf, tableName, readRatio, totalSegments);
Date startTime = new Date();
System.out.println("Job started: " + startTime);
JobClient.runJob(jobConf);
Date endTime = new Date();
System.out.println("Job ended: " + endTime);
System.out.println("The job took " + (endTime.getTime() - startTime.getTime()) / 1000 + " "
+ "seconds.");
System.out.println("Output path: " + outputPath);
return 0;
}