Package com.ontology2.bakemono.joins

Source Code of com.ontology2.bakemono.joins.FetchTriplesWithMatchingObjectsMapper

package com.ontology2.bakemono.joins;

import com.google.common.collect.Maps;
import com.ontology2.bakemono.primitiveTriples.PrimitiveTriple;
import com.ontology2.bakemono.primitiveTriples.PrimitiveTripleCodec;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.VIntWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Mapper;

import java.util.Map;

public class FetchTriplesWithMatchingObjectsMapper extends GeneralTextJoinMapper {

    private static final Text EMPTY =new Text("");
    private static final PrimitiveTripleCodec ptc=new PrimitiveTripleCodec();

    @Override
    public Map.Entry<Text, Text> splitValue(Writable value, VIntWritable tag) {
        switch(tag.get()) {
            case 1:
                return Maps.immutableEntry((Text) value, EMPTY);
            case 2:
                PrimitiveTriple triple=ptc.decode(value.toString());
                return Maps.immutableEntry(new Text(triple.getObject()),(Text) value);
        }

        return Maps.immutableEntry((Text) value, (Text) value);
    }
}
TOP

Related Classes of com.ontology2.bakemono.joins.FetchTriplesWithMatchingObjectsMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.