Search in sources :

Example 41 with LongWritable

use of org.apache.hadoop.io.LongWritable in project jena by apache.

the class TriplesToQuadsBySubjectMapperTest method triples_to_quads_mapper_01.

/**
     * Tests quads to triples conversion
     * 
     * @throws IOException
     */
@Test
public void triples_to_quads_mapper_01() throws IOException {
    MapDriver<LongWritable, TripleWritable, LongWritable, QuadWritable> driver = this.getMapDriver();
    Triple t = new Triple(NodeFactory.createURI("http://s"), NodeFactory.createURI("http://p"), NodeFactory.createLiteral("test"));
    Quad q = new Quad(t.getSubject(), t);
    driver.withInput(new Pair<LongWritable, TripleWritable>(new LongWritable(1), new TripleWritable(t))).withOutput(new Pair<LongWritable, QuadWritable>(new LongWritable(1), new QuadWritable(q)));
    driver.runTest();
}
Also used : Triple(org.apache.jena.graph.Triple) TripleWritable(org.apache.jena.hadoop.rdf.types.TripleWritable) Quad(org.apache.jena.sparql.core.Quad) QuadWritable(org.apache.jena.hadoop.rdf.types.QuadWritable) LongWritable(org.apache.hadoop.io.LongWritable) Pair(org.apache.hadoop.mrunit.types.Pair) Test(org.junit.Test)

Example 42 with LongWritable

use of org.apache.hadoop.io.LongWritable in project jena by apache.

the class TriplesToQuadsConstantGraphMapperTest method generateData.

protected void generateData(MapDriver<LongWritable, TripleWritable, LongWritable, QuadWritable> driver, int num) {
    for (int i = 0; i < num; i++) {
        Triple t = new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
        Quad q = new Quad(Quad.defaultGraphNodeGenerated, t);
        driver.addInput(new LongWritable(i), new TripleWritable(t));
        driver.addOutput(new LongWritable(i), new QuadWritable(q));
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Quad(org.apache.jena.sparql.core.Quad) TripleWritable(org.apache.jena.hadoop.rdf.types.TripleWritable) QuadWritable(org.apache.jena.hadoop.rdf.types.QuadWritable) LongWritable(org.apache.hadoop.io.LongWritable)

Example 43 with LongWritable

use of org.apache.hadoop.io.LongWritable in project jena by apache.

the class AbstractNodeTupleFilterTests method generateData.

protected final void generateData(MapDriver<LongWritable, T, LongWritable, T> driver, int num) {
    for (int i = 0; i < num; i++) {
        LongWritable key = new LongWritable(i);
        if (i % 2 == 0 && !this.noValidInputs()) {
            T value = this.createValidValue(i);
            driver.addInput(key, value);
            if (!this.isInverted())
                driver.addOutput(key, value);
        } else {
            T value = this.createInvalidValue(i);
            driver.addInput(key, value);
            if (this.isInverted())
                driver.addOutput(key, value);
        }
    }
}
Also used : LongWritable(org.apache.hadoop.io.LongWritable)

Example 44 with LongWritable

use of org.apache.hadoop.io.LongWritable in project jena by apache.

the class AbstractNodeTupleGroupingTests method generateData.

/**
     * Generates data for use in tests
     * 
     * @param driver
     *            Driver
     * @param num
     *            Number of tuples to generate
     */
protected void generateData(MapDriver<LongWritable, T, NodeWritable, T> driver, int num) {
    for (int i = 0; i < num; i++) {
        LongWritable inputKey = new LongWritable(i);
        T value = this.createValue(i);
        NodeWritable outputKey = this.getOutputKey(value);
        driver.addInput(inputKey, value);
        driver.addOutput(outputKey, value);
    }
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) LongWritable(org.apache.hadoop.io.LongWritable)

Example 45 with LongWritable

use of org.apache.hadoop.io.LongWritable in project jena by apache.

the class AbstractNodeTupleSplitToNodesTests method generateData.

/**
     * Generates data for use in tests
     * 
     * @param driver
     *            Driver
     * @param num
     *            Number of tuples to generate
     */
protected void generateData(MapDriver<LongWritable, T, LongWritable, NodeWritable> driver, int num) {
    for (int i = 0; i < num; i++) {
        LongWritable key = new LongWritable(i);
        T value = this.createValue(i);
        NodeWritable[] nodes = this.getNodes(value);
        driver.addInput(key, value);
        for (NodeWritable n : nodes) {
            driver.addOutput(key, n);
        }
    }
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) LongWritable(org.apache.hadoop.io.LongWritable)

Aggregations

LongWritable (org.apache.hadoop.io.LongWritable)445 Text (org.apache.hadoop.io.Text)220 Test (org.junit.Test)171 IntWritable (org.apache.hadoop.io.IntWritable)102 Path (org.apache.hadoop.fs.Path)99 BytesWritable (org.apache.hadoop.io.BytesWritable)70 FloatWritable (org.apache.hadoop.io.FloatWritable)68 Configuration (org.apache.hadoop.conf.Configuration)62 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)62 BooleanWritable (org.apache.hadoop.io.BooleanWritable)60 ArrayList (java.util.ArrayList)59 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)57 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)53 IOException (java.io.IOException)49 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)48 SequenceFile (org.apache.hadoop.io.SequenceFile)42 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)40 FileSystem (org.apache.hadoop.fs.FileSystem)37 JobConf (org.apache.hadoop.mapred.JobConf)37 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)35