private static int count = 0;
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
OutputJobInfo jobInfo = (OutputJobInfo) HCatUtil.deserialize(context.getConfiguration().get(HCatConstants.HCAT_KEY_OUTPUT_INFO));
HCatRecord record = new DefaultHCatRecord(3);
HCatSchema schema = jobInfo.getOutputSchema();
String vals[] = value.toString().split(",");
record.setInteger("key", schema, Integer.parseInt(vals[0]));
synchronized (MapWriteAbortTransaction.class) {
if (count == 2) {
failedKey = vals[0];
throw new IOException("Failing map to test abort");
}
for (int i = 1; i < vals.length; i++) {
String pair[] = vals[i].split(":");
record.set(pair[0], schema, pair[1]);
}
context.write(null, record);
count++;
}