Search in sources :

Example 16 with TripleWritable

use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.

the class TriplesToQuadsConstantGraphMapperTest 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(Quad.defaultGraphNodeGenerated, 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 17 with TripleWritable

use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.

the class TestDistinctTriples method distinct_triples_01.

@Test
public void distinct_triples_01() throws IOException {
    MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this.getMapReduceDriver();
    Triple t = new Triple(NodeFactory.createURI("urn:s"), NodeFactory.createURI("urn:p"), NodeFactory.createLiteral("1"));
    TripleWritable tw = new TripleWritable(t);
    driver.addInput(new LongWritable(1), tw);
    driver.addOutput(NullWritable.get(), tw);
    driver.runTest();
}
Also used : Triple(org.apache.jena.graph.Triple) TripleWritable(org.apache.jena.hadoop.rdf.types.TripleWritable) LongWritable(org.apache.hadoop.io.LongWritable) NullWritable(org.apache.hadoop.io.NullWritable) Test(org.junit.Test)

Example 18 with TripleWritable

use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.

the class QuadsToTriplesMapperTest method generateData.

protected void generateData(MapDriver<LongWritable, QuadWritable, LongWritable, TripleWritable> 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 QuadWritable(q));
        driver.addOutput(new LongWritable(i), new TripleWritable(t));
    }
}
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)

Aggregations

TripleWritable (org.apache.jena.hadoop.rdf.types.TripleWritable)18 Triple (org.apache.jena.graph.Triple)15 LongWritable (org.apache.hadoop.io.LongWritable)12 Test (org.junit.Test)9 QuadWritable (org.apache.jena.hadoop.rdf.types.QuadWritable)8 Quad (org.apache.jena.sparql.core.Quad)7 NullWritable (org.apache.hadoop.io.NullWritable)6 IOException (java.io.IOException)3 Pair (org.apache.hadoop.mrunit.types.Pair)3 ArrayList (java.util.ArrayList)2 Node (org.apache.jena.graph.Node)2 StringWriter (java.io.StringWriter)1 Configuration (org.apache.hadoop.conf.Configuration)1 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 NodeTupleWritable (org.apache.jena.hadoop.rdf.types.NodeTupleWritable)1 NodeWritable (org.apache.jena.hadoop.rdf.types.NodeWritable)1