List of usage examples for org.apache.hadoop.mapreduce MapContext getInputSplit
public InputSplit getInputSplit();
From source file:datafu.hourglass.mapreduce.PartitioningMapper.java
License:Apache License
@SuppressWarnings("unchecked") @Override/* w w w . j a v a 2 s.c om*/ public void map(Object inputObj, MapContext<Object, Object, Object, Object> context) throws IOException, InterruptedException { long time; if (_lastSplit == context.getInputSplit()) { time = _lastTime; } else { _lastSplit = (FileSplit) context.getInputSplit(); time = PathUtils.getDateForNestedDatedPath((_lastSplit).getPath().getParent()).getTime(); _lastTime = time; } getMapCollector().setContext(context); // Set the time, representing the time range this data was derived from. // The key is tagged with this time. getMapCollector().setTime(time); try { AvroKey<GenericRecord> input = (AvroKey<GenericRecord>) inputObj; getMapper().map(input.datum(), getMapCollector()); } catch (InterruptedException e) { throw new IOException(e); } }
From source file:org.apache.pig.backend.hadoop.streaming.HadoopExecutableManager.java
License:Apache License
private void writeDebugHeader() { processError("===== Task Information Header ====="); processError("\nCommand: " + command); processError("\nStart time: " + new Date(System.currentTimeMillis())); if (job.getBoolean(MRConfiguration.TASK_IS_MAP, false)) { MapContext context = (MapContext) PigMapReduce.sJobContext; PigSplit pigSplit = (PigSplit) context.getInputSplit(); int numPaths = pigSplit.getNumPaths(); processError("\nPigSplit contains " + numPaths + " wrappedSplits."); StringBuilder sb = new StringBuilder(); for (int i = 0; i < numPaths; i++) { InputSplit wrappedSplit = pigSplit.getWrappedSplit(i); if (wrappedSplit instanceof FileSplit) { FileSplit mapInputFileSplit = (FileSplit) wrappedSplit; sb.append("\nInput-split: file="); sb.append(mapInputFileSplit.getPath()); sb.append(" start-offset="); sb.append(Long.toString(mapInputFileSplit.getStart())); sb.append(" length="); sb.append(Long.toString(mapInputFileSplit.getLength())); processError(sb.toString()); sb.setLength(0);// w w w . ja v a 2 s . com } } } processError("\n===== * * * =====\n"); }
From source file:org.warcbase.mapreduce.lib.ChainMapContextImpl.java
License:Apache License
@Override public InputSplit getInputSplit() { if (base instanceof MapContext) { MapContext<KEYIN, VALUEIN, KEYOUT, VALUEOUT> mc = (MapContext<KEYIN, VALUEIN, KEYOUT, VALUEOUT>) base; return mc.getInputSplit(); } else {//from w ww . j a va 2s.c o m return null; } }