Example usage for org.apache.hadoop.mapreduce MRJobConfig MAP_INPUT_PATH

List of usage examples for org.apache.hadoop.mapreduce MRJobConfig MAP_INPUT_PATH

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce MRJobConfig MAP_INPUT_PATH.

Prototype

String MAP_INPUT_PATH

To view the source code for org.apache.hadoop.mapreduce MRJobConfig MAP_INPUT_PATH.

Click Source Link

Usage

From source file:net.thevis.groovyhadoop.backport.CombineFileRecordReader.java

License:Apache License

/**
 * Get the record reader for the next chunk in this CombineFileSplit.
 *///  w  w w  .j  av a  2  s.co  m
protected boolean initNextRecordReader() throws IOException {

    if (curReader != null) {
        curReader.close();
        curReader = null;
        if (idx > 0) {
            progress += split.getLength(idx - 1); // done processing so far
        }
    }

    // if all chunks have been processed, nothing more to do.
    if (idx == split.getNumPaths()) {
        return false;
    }

    // get a record reader for the idx-th chunk
    try {
        Configuration conf = context.getConfiguration();
        // setup some helper config variables.
        conf.set(MRJobConfig.MAP_INPUT_FILE, split.getPath(idx).toString());
        conf.setLong(MRJobConfig.MAP_INPUT_START, split.getOffset(idx));
        conf.setLong(MRJobConfig.MAP_INPUT_PATH, split.getLength(idx));

        curReader = rrConstructor.newInstance(new Object[] { split, context, Integer.valueOf(idx) });

        if (idx > 0) {
            // initialize() for the first RecordReader will be called by MapTask;
            // we're responsible for initializing subsequent RecordReaders.
            curReader.initialize(split, context);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    idx++;
    return true;
}