Search in sources :

Example 1 with Serialization

use of org.apache.hadoop.io.serializer.Serialization in project hadoop by apache.

the class Chain method getMapperCollector.

/**
   * Returns the OutputCollector to be used by a Mapper instance in the chain.
   *
   * @param mapperIndex index of the Mapper instance to get the OutputCollector.
   * @param output      the original OutputCollector of the task.
   * @param reporter    the reporter of the task.
   * @return the OutputCollector to be used in the chain.
   */
@SuppressWarnings({ "unchecked" })
public OutputCollector getMapperCollector(int mapperIndex, OutputCollector output, Reporter reporter) {
    Serialization keySerialization = mappersKeySerialization.get(mapperIndex);
    Serialization valueSerialization = mappersValueSerialization.get(mapperIndex);
    return new ChainOutputCollector(mapperIndex, keySerialization, valueSerialization, output, reporter);
}
Also used : Serialization(org.apache.hadoop.io.serializer.Serialization)

Example 2 with Serialization

use of org.apache.hadoop.io.serializer.Serialization in project ignite by apache.

the class HadoopV2TaskContext method readExternalSplit.

/**
     * @param split External split.
     * @return Native input split.
     * @throws IgniteCheckedException If failed.
     */
@SuppressWarnings("unchecked")
private Object readExternalSplit(HadoopExternalSplit split) throws IgniteCheckedException {
    Path jobDir = new Path(jobConf().get(MRJobConfig.MAPREDUCE_JOB_DIR));
    FileSystem fs;
    try {
        fs = fileSystemForMrUserWithCaching(jobDir.toUri(), jobConf(), fsMap);
    } catch (IOException e) {
        throw new IgniteCheckedException(e);
    }
    try (FSDataInputStream in = fs.open(JobSubmissionFiles.getJobSplitFile(jobDir))) {
        in.seek(split.offset());
        String clsName = Text.readString(in);
        Class<?> cls = jobConf().getClassByName(clsName);
        assert cls != null;
        Serialization serialization = new SerializationFactory(jobConf()).getSerialization(cls);
        Deserializer deserializer = serialization.getDeserializer(cls);
        deserializer.open(in);
        Object res = deserializer.deserialize(null);
        deserializer.close();
        assert res != null;
        return res;
    } catch (IOException | ClassNotFoundException e) {
        throw new IgniteCheckedException(e);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) SerializationFactory(org.apache.hadoop.io.serializer.SerializationFactory) IOException(java.io.IOException) WritableSerialization(org.apache.hadoop.io.serializer.WritableSerialization) HadoopSerialization(org.apache.ignite.internal.processors.hadoop.HadoopSerialization) Serialization(org.apache.hadoop.io.serializer.Serialization) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Deserializer(org.apache.hadoop.io.serializer.Deserializer) FileSystem(org.apache.hadoop.fs.FileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream)

Aggregations

Serialization (org.apache.hadoop.io.serializer.Serialization)2 IOException (java.io.IOException)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 LocalFileSystem (org.apache.hadoop.fs.LocalFileSystem)1 Path (org.apache.hadoop.fs.Path)1 Deserializer (org.apache.hadoop.io.serializer.Deserializer)1 SerializationFactory (org.apache.hadoop.io.serializer.SerializationFactory)1 WritableSerialization (org.apache.hadoop.io.serializer.WritableSerialization)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 HadoopSerialization (org.apache.ignite.internal.processors.hadoop.HadoopSerialization)1