View<Record> source = load(datasets.get(0), Record.class);
View<Record> dest = load(datasets.get(1), Record.class);
TaskUtil.configure(getConf()).addJars(jars);
TransformTask task;
if (transform != null) {
DoFn<Record, Record> transformFn;
try {
DynConstructors.Ctor<DoFn<Record, Record>> ctor =
new DynConstructors.Builder(DoFn.class)
.loader(loaderForJars(jars))
.impl(transform)
.buildChecked();
transformFn = ctor.newInstance();
} catch (NoSuchMethodException e) {
throw new DatasetException(
"Cannot find no-arg constructor for class: " + transform, e);
}
task = new TransformTask<Record, Record>(source, dest, transformFn);
} else {
task = new CopyTask<Record>(source, dest);
}
task.setConf(getConf());
if (noCompaction) {
task.noCompaction();
}
if (numWriters >= 0) {
task.setNumWriters(numWriters);
}
PipelineResult result = task.run();
if (result.succeeded()) {
console.info("Added {} records to \"{}\"",
task.getCount(), datasets.get(1));
return 0;
} else {
return 1;
}
}