@Override
public RecordReader<KEY, VALUE> createRecordReader(final InputSplit split,
final TaskAttemptContext context)
throws IOException, InterruptedException {
DataSetInputSplit inputSplit = (DataSetInputSplit) split;
Configuration conf = context.getConfiguration();
SparkContextProvider contextProvider = new SparkContextProvider(context.getConfiguration());
BasicSparkContext sparkContext = contextProvider.get();
//TODO: Metrics should be started here when implemented
String dataSetName = getInputName(conf);
BatchReadable<KEY, VALUE> inputDataset = (BatchReadable<KEY, VALUE>) sparkContext.getDataSet(dataSetName);
SplitReader<KEY, VALUE> splitReader = inputDataset.createSplitReader(inputSplit.getSplit());
// the record reader now owns the context and will close it
return new DatasetRecordReader<KEY, VALUE>(splitReader, sparkContext, dataSetName);
}