public static class Reduce extends Reducer<LongWritable, Text, Text, Text> {
@Override
protected void reduce(LongWritable key, Iterable<Text> values, Context ctx) throws IOException,
InterruptedException {
StorageHelper helper = new StorageHelper(ctx);
boolean snappy = ctx.getConfiguration().getBoolean(CFG_PREFIX + OPT_PRIAM, false);
String base = ctx.getConfiguration().get(CFG_PREFIX + OPT_RECURSIVE);
if (base != null && !base.endsWith("/")) {
base = base + "/";
}
for (Text file : values) {
String fileString = cleanS3(file.toString().trim());
if (base == null) {
helper.copyToTemp(fileString, snappy);
} else {
String prefix = fileString.substring(base.length());
prefix = prefix.replaceAll("/[^/]+$", "");
helper.copyToTemp(fileString, prefix, snappy);
}
}
}