All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ontology2.bakemono.mapmap.MapMapper Maven / Gradle / Ivy

There is a newer version: 3.2
Show newest version
package com.ontology2.bakemono.mapmap;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.ontology2.bakemono.abstractions.Codec;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public abstract class MapMapper
        extends Mapper {

    // converting from Text to String is lame, but so what

    abstract Codec getCodec();
    abstract Function getKeyFunction();
    abstract Function getValueFunction();

    @Override
    protected void setup(Context context) throws IOException, InterruptedException {
        super.setup(context);
    }

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        InnerType row=getCodec().decode(value.toString());
        OutKey outKey=getKeyFunction().apply(row);
        OutValue outValue=getValueFunction().apply(row);

        if(outKey!=null && outValue!=null) {
            context.write(
                    outKey
                    ,outValue
            );
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy