Example usage for org.apache.hadoop.mapreduce JobContext getOutputKeyClass

List of usage examples for org.apache.hadoop.mapreduce JobContext getOutputKeyClass

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce JobContext getOutputKeyClass.

Prototype

public Class<?> getOutputKeyClass();

Source Link

Document

Get the key class for the job output data.

Usage

From source file:edu.arizona.cs.hadoop.fs.irods.output.HirodsSequenceFileAsBinaryOutputFormat.java

License:Apache License

/**
 * Get the key class for the {@link SequenceFile}
 *
 * @return the key class of the {@link SequenceFile}
 *///from www  . j a va2  s .co  m
static public Class<? extends WritableComparable> getSequenceFileOutputKeyClass(JobContext job) {
    return job.getConfiguration().getClass(KEY_CLASS,
            job.getOutputKeyClass().asSubclass(WritableComparable.class), WritableComparable.class);
}

From source file:edu.uci.ics.hyracks.dataflow.hadoop.HadoopReducerOperatorDescriptor.java

License:Apache License

public static RecordDescriptor getRecordDescriptor(JobConf conf, IHadoopClassFactory classFactory) {
    String outputKeyClassName = null;
    String outputValueClassName = null;

    if (conf.getUseNewMapper()) {
        JobContext context = new ContextFactory().createJobContext(conf);
        outputKeyClassName = context.getOutputKeyClass().getName();
        outputValueClassName = context.getOutputValueClass().getName();
    } else {//from   w w w  .  jav  a 2s  . c  om
        outputKeyClassName = conf.getOutputKeyClass().getName();
        outputValueClassName = conf.getOutputValueClass().getName();
    }

    RecordDescriptor recordDescriptor = null;
    try {
        if (classFactory == null) {
            recordDescriptor = DatatypeHelper.createKeyValueRecordDescriptor(
                    (Class<? extends Writable>) Class.forName(outputKeyClassName),
                    (Class<? extends Writable>) Class.forName(outputValueClassName));
        } else {
            recordDescriptor = DatatypeHelper.createKeyValueRecordDescriptor(
                    (Class<? extends Writable>) classFactory.loadClass(outputKeyClassName),
                    (Class<? extends Writable>) classFactory.loadClass(outputValueClassName));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return recordDescriptor;
}