List of usage examples for org.apache.hadoop.mapreduce TaskID getTaskType
public TaskType getTaskType()
From source file:simsql.runtime.RecordOutputFormat.java
License:Apache License
public RecordWriter<WritableKey, WritableValue> getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException { Configuration conf = job.getConfiguration(); // here's what we do -- if we have a map-only job and a value for // lastInputSplit as given to us by RecordInputFormat, then we // will get our part number from that file. otherwise, we'll use // the one we get from the job. // get the part from the job. TaskID taskId = job.getTaskAttemptID().getTaskID(); int part = taskId.getId(); if (RecordOutputFormat.lastInputSplit != null && taskId.getTaskType() == TaskType.MAP) { part = RecordOutputFormat.getPartNumber(RecordOutputFormat.lastInputSplit); System.out.println("MAP-ONLY JOB: USING PART NUMBER " + part + " FROM INPUT SPLIT"); // set it back to null RecordOutputFormat.lastInputSplit = null; }//from w w w .java2s . c o m FileOutputCommitter committer = (FileOutputCommitter) getOutputCommitter(job); Path file = new Path(committer.getWorkPath(), RecordOutputFormat.getFileNumber(part)); /* Path file = getDefaultWorkFile (job, ".tbl"); */ FileSystem fs = file.getFileSystem(conf); FSDataOutputStream fileOut = fs.create(file, false); return new OutputFileSerializer(fileOut); }