Search in sources :

Example 46 with Quad

use of org.apache.jena.sparql.core.Quad in project jena by apache.

the class OpQuad method equivalent.

public boolean equivalent(OpQuadPattern opQuads) {
    QuadPattern quads = opQuads.getPattern();
    if (quads.size() != 1)
        return false;
    Quad q = quads.get(0);
    return quad.equals(q);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) QuadPattern(org.apache.jena.sparql.core.QuadPattern)

Example 47 with Quad

use of org.apache.jena.sparql.core.Quad in project jena by apache.

the class OpQuadBlock method convertOp.

/** Convenience - convert to OpQuadPatterns which are more widely used (currently?) */
public Op convertOp() {
    if (quads.size() == 0)
        return OpTable.empty();
    if (quads.size() == 1) {
        Quad q = quads.get(0);
        BasicPattern bgp = new BasicPattern();
        bgp.add(q.asTriple());
        return new OpQuadPattern(q.getGraph(), bgp);
    }
    List<OpQuadPattern> x = convert();
    OpSequence ops = OpSequence.create();
    for (OpQuadPattern oqp : x) ops.add(oqp);
    return ops;
}
Also used : Quad(org.apache.jena.sparql.core.Quad) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 48 with Quad

use of org.apache.jena.sparql.core.Quad in project jena by apache.

the class RdfTypesTest method quad_writable_02.

/**
     * Basic quad writable round tripping test
     * 
     * @throws IOException
     * @throws InstantiationException
     * @throws IllegalAccessException
     * @throws ClassNotFoundException
     */
@Test
public void quad_writable_02() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
    Quad q = new Quad(Quad.defaultGraphNodeGenerated, NodeFactory.createBlankNode(), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral("value"));
    QuadWritable qw = new QuadWritable(q);
    testWriteRead(qw, qw);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) QuadWritable(org.apache.jena.hadoop.rdf.types.QuadWritable) Test(org.junit.Test)

Example 49 with Quad

use of org.apache.jena.sparql.core.Quad in project jena by apache.

the class QuadWritable method write.

@Override
public void write(DataOutput output) throws IOException {
    if (this.get() == null)
        throw new IOException("Null quads cannot be written using this class, consider using NodeTupleWritable instead");
    // May not have yet prepared the Thrift triple
    if (!this.quad.isSetS()) {
        Quad tuple = this.get();
        this.quad.setG(ThriftConvert.convert(tuple.getGraph(), false));
        this.quad.setS(ThriftConvert.convert(tuple.getSubject(), false));
        this.quad.setP(ThriftConvert.convert(tuple.getPredicate(), false));
        this.quad.setO(ThriftConvert.convert(tuple.getObject(), false));
    }
    byte[] buffer;
    try {
        buffer = ThriftConverter.toBytes(this.quad);
    } catch (TException e) {
        throw new IOException(e);
    }
    output.writeInt(buffer.length);
    output.write(buffer);
}
Also used : TException(org.apache.thrift.TException) Quad(org.apache.jena.sparql.core.Quad) RDF_Quad(org.apache.jena.riot.thrift.wire.RDF_Quad) IOException(java.io.IOException)

Example 50 with Quad

use of org.apache.jena.sparql.core.Quad in project jena by apache.

the class RdfTypesTest method quad_writable_01.

/**
     * Basic quad writable round tripping test
     * 
     * @throws IOException
     * @throws InstantiationException
     * @throws IllegalAccessException
     * @throws ClassNotFoundException
     */
@Test
public void quad_writable_01() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
    Quad q = new Quad(Quad.defaultGraphNodeGenerated, NodeFactory.createURI("http://example"), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral("value"));
    QuadWritable qw = new QuadWritable(q);
    testWriteRead(qw, qw);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) QuadWritable(org.apache.jena.hadoop.rdf.types.QuadWritable) Test(org.junit.Test)

Aggregations

Quad (org.apache.jena.sparql.core.Quad)161 Test (org.junit.Test)91 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)49 Node (org.apache.jena.graph.Node)36 BaseTest (org.apache.jena.atlas.junit.BaseTest)32 Triple (org.apache.jena.graph.Triple)25 UpdateBuilder (org.apache.jena.arq.querybuilder.UpdateBuilder)14 Update (org.apache.jena.update.Update)14 QuadWritable (org.apache.jena.hadoop.rdf.types.QuadWritable)12 ResultSet (java.sql.ResultSet)8 ArrayList (java.util.ArrayList)8 TripleWritable (org.apache.jena.hadoop.rdf.types.TripleWritable)7 Var (org.apache.jena.sparql.core.Var)7 LongWritable (org.apache.hadoop.io.LongWritable)6 UpdateDataDelete (org.apache.jena.sparql.modify.request.UpdateDataDelete)6 UpdateDataInsert (org.apache.jena.sparql.modify.request.UpdateDataInsert)6 Element (org.apache.jena.sparql.syntax.Element)6 Graph (org.apache.jena.graph.Graph)5 BasicPattern (org.apache.jena.sparql.core.BasicPattern)4 IOException (java.io.IOException)3