in source/benchmark-sample/tpcds-gen/src/main/java/org/notmysock/tpcds/GenTable.java [171:216]
protected void map(LongWritable offset, Text command, Mapper.Context context)
throws IOException, InterruptedException {
String parallel="1";
String child="1";
String[] cmd = command.toString().split(" ");
for(int i=0; i<cmd.length; i++) {
if(cmd[i].equals("$DIR")) {
cmd[i] = (new File(".")).getAbsolutePath();
}
if(cmd[i].equals("-parallel")) {
parallel = cmd[i+1];
}
if(cmd[i].equals("-child")) {
child = cmd[i+1];
}
}
Process p = Runtime.getRuntime().exec(cmd, null, new File("dsdgen/tools/"));
int status = p.waitFor();
if(status != 0) {
String err = readToString(p.getErrorStream());
throw new InterruptedException("Process failed with status code " + status + "\n" + err);
}
File cwd = new File(".");
final String suffix = String.format("_%s_%s.dat", child, parallel);
FilenameFilter tables = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(suffix);
}
};
for(File f: cwd.listFiles(tables)) {
BufferedReader br = new BufferedReader(new FileReader(f));
String line;
while ((line = br.readLine()) != null) {
// process the line.
mos.write("text", line, null, f.getName().replace(suffix,"/data"));
}
br.close();
f.deleteOnExit();
}
}