Search in sources :

Example 51 with Quad

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

the class QuadWritable method readFields.

@Override
public void readFields(DataInput input) throws IOException {
    this.quad.clear();
    int tripleLength = input.readInt();
    byte[] buffer = new byte[tripleLength];
    input.readFully(buffer);
    try {
        ThriftConverter.fromBytes(buffer, this.quad);
    } catch (TException e) {
        throw new IOException(e);
    }
    this.setInternal(new Quad(ThriftConvert.convert(this.quad.getG()), ThriftConvert.convert(this.quad.getS()), ThriftConvert.convert(this.quad.getP()), ThriftConvert.convert(this.quad.getO())));
}
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 52 with Quad

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

the class FusekiLib method addDataInto.

public static void addDataInto(DatasetGraph src, DatasetGraph dest) {
    Iterator<Quad> iter = src.find(Node.ANY, Node.ANY, Node.ANY, Node.ANY);
    for (; iter.hasNext(); ) {
        Quad q = iter.next();
        dest.add(q);
    }
    PrefixMapping pmapSrc = src.getDefaultGraph().getPrefixMapping();
    PrefixMapping pmapDest = dest.getDefaultGraph().getPrefixMapping();
    pmapDest.withDefaultMappings(pmapSrc);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 53 with Quad

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

the class Template method equalIso.

public boolean equalIso(Object temp2, NodeIsomorphismMap labelMap) {
    if (!(temp2 instanceof Template))
        return false;
    Template tg2 = (Template) temp2;
    List<Quad> list1 = this.getQuads();
    List<Quad> list2 = tg2.getQuads();
    if (list1.size() != list2.size())
        return false;
    for (int i = 0; i < list1.size(); i++) {
        Quad q1 = list1.get(i);
        Quad q2 = list2.get(i);
        boolean iso = Iso.quadIso(q1, q2, labelMap);
        if (!iso) {
            return false;
        }
    }
    return true;
}
Also used : Quad(org.apache.jena.sparql.core.Quad) FormatterTemplate(org.apache.jena.sparql.serializer.FormatterTemplate)

Example 54 with Quad

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

the class BuilderGraph method buildDataset.

public static DatasetGraph buildDataset(DatasetGraph dsg, ItemList list) {
    BuilderLib.checkTag(list, Tags.tagDataset);
    list = list.cdr();
    for (Item item : list) {
        if (!item.isTagged(Tags.tagGraph)) {
            // Not (graph ...) so it's (quad), short form quad or an error.
            Quad q = BuilderGraph.buildQuad(item.getList(), "Expected (graph ...) or a quad () as elements of a dataset");
            dsg.add(q);
            continue;
        }
        Node name = null;
        ItemList graphContent = item.getList().cdr();
        if (!graphContent.isEmpty() && graphContent.car().isNode()) {
            name = graphContent.car().getNode();
            graphContent = graphContent.cdr();
        }
        Graph g;
        if (name == null) {
            g = dsg.getDefaultGraph();
            if (g == null) {
                g = GraphFactory.createDefaultGraph();
                dsg.setDefaultGraph(g);
            }
        } else {
            g = dsg.getGraph(name);
            if (g == null) {
                g = GraphFactory.createDefaultGraph();
                dsg.addGraph(name, g);
            }
        }
        BuilderGraph.buildGraph(g, graphContent);
    }
    return dsg;
}
Also used : Item(org.apache.jena.sparql.sse.Item) Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) Node(org.apache.jena.graph.Node) ItemList(org.apache.jena.sparql.sse.ItemList)

Example 55 with Quad

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

the class BuilderGraph method _buildNode4.

private static Quad _buildNode4(ItemList list) {
    Node g = null;
    if (list.get(0).equals(Item.defaultItem))
        g = Quad.defaultGraphNodeGenerated;
    else
        g = BuilderNode.buildNode(list.get(0));
    Node s = BuilderNode.buildNode(list.get(1));
    Node p = BuilderNode.buildNode(list.get(2));
    Node o = BuilderNode.buildNode(list.get(3));
    return new Quad(g, s, p, o);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Node(org.apache.jena.graph.Node)

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