fieldDelimiter = Data.DEFAULT_FIELD_DELIMITER;
}
@Override
public void load(LoaderContext context, Object oc, Object oj) throws Exception {
DataReader reader = context.getDataReader();
reader.setFieldDelimiter(fieldDelimiter);
Configuration conf = new Configuration();
// Configuration conf = ((EtlContext)context).getConfiguration();
String filename = context.getString(JobConstants.JOB_MR_OUTPUT_FILE);
String codecname = context.getString(JobConstants.JOB_MR_OUTPUT_CODEC);
CompressionCodec codec = null;
if (codecname != null) {
Class<?> clz = ClassUtils.loadClass(codecname);
if (clz == null) {
throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0009, codecname);
}
try {
codec = (CompressionCodec) clz.newInstance();
if (codec instanceof Configurable) {
((Configurable) codec).setConf(conf);
}
} catch (Exception e) {
throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0010, codecname, e);
}
}
filename += EXTENSION;
try {
Path filepath = new Path(filename);
SequenceFile.Writer filewriter;
if (codec != null) {
filewriter = SequenceFile.createWriter(filepath.getFileSystem(conf),
conf, filepath, Text.class, NullWritable.class,
CompressionType.BLOCK, codec);
} else {
filewriter = SequenceFile.createWriter(filepath.getFileSystem(conf),
conf, filepath, Text.class, NullWritable.class, CompressionType.NONE);
}
String csv;
Text text = new Text();
while ((csv = reader.readCsvRecord()) != null) {
text.set(csv);
filewriter.append(text, NullWritable.get());
}
filewriter.close();