use of co.cask.cdap.internal.app.runtime.batch.dataset.DatasetOutputFormatProvider in project cdap by caskdata.
the class BasicMapReduceContext method addOutput.
@Override
public void addOutput(Output output) {
if (output instanceof Output.DatasetOutput) {
Output.DatasetOutput datasetOutput = ((Output.DatasetOutput) output);
String datasetNamespace = datasetOutput.getNamespace();
if (datasetNamespace == null) {
datasetNamespace = getNamespace();
}
String datasetName = output.getName();
Map<String, String> arguments = ((Output.DatasetOutput) output).getArguments();
// we can delay the instantiation of the Dataset to later, but for now, we still have to maintain backwards
// compatibility for the #setOutput(String, Dataset) method, so delaying the instantiation of this dataset will
// bring about code complexity without much benefit. Once #setOutput(String, Dataset) is removed, we can postpone
// this dataset instantiation
DatasetOutputFormatProvider outputFormatProvider = new DatasetOutputFormatProvider(datasetNamespace, datasetName, arguments, getDataset(datasetNamespace, datasetName, arguments, AccessType.WRITE), MapReduceBatchWritableOutputFormat.class);
addOutput(output.getAlias(), outputFormatProvider);
} else if (output instanceof Output.OutputFormatProviderOutput) {
addOutput(output.getAlias(), ((Output.OutputFormatProviderOutput) output).getOutputFormatProvider());
} else {
// shouldn't happen unless user defines their own Output class
throw new IllegalArgumentException(String.format("Output %s has unknown output class %s", output.getName(), output.getClass().getCanonicalName()));
}
}
Aggregations