Search in sources :

Example 1 with BasicPattern

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

the class OpExecutor method execute.

// ---- All the cases
protected QueryIterator execute(OpBGP opBGP, QueryIterator input) {
    BasicPattern pattern = opBGP.getPattern();
    QueryIterator qIter = stageGenerator.execute(pattern, input, execCxt);
    if (hideBNodeVars)
        qIter = new QueryIterDistinguishedVars(qIter, execCxt);
    return qIter;
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 2 with BasicPattern

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

the class GraphSPARQLService method graphBaseFind.

//    @Override
//    public Capabilities getCapabilities()
//    { 
//    	if (capabilities == null)
//            capabilities = new AllCapabilities()
//        	  { @Override public boolean handlesLiteralTyping() { return false; } };
//        return capabilities;
//    }
@Override
protected ExtendedIterator<Triple> graphBaseFind(Triple m) {
    Node s = m.getMatchSubject();
    Var sVar = null;
    if (s == null) {
        sVar = Var.alloc("s");
        s = sVar;
    }
    Node p = m.getMatchPredicate();
    Var pVar = null;
    if (p == null) {
        pVar = Var.alloc("p");
        p = pVar;
    }
    Node o = m.getMatchObject();
    Var oVar = null;
    if (o == null) {
        oVar = Var.alloc("o");
        o = oVar;
    }
    Triple triple = new Triple(s, p, o);
    // Evaluate as an algebra expression
    BasicPattern pattern = new BasicPattern();
    pattern.add(triple);
    Op op = new OpBGP(pattern);
    //        return WrappedIterator.createNoRemove(triples.iterator()) ;
    return null;
}
Also used : Triple(org.apache.jena.graph.Triple) Op(org.apache.jena.sparql.algebra.Op) Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 3 with BasicPattern

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

the class NodeTransformOp method transform.

@Override
public Op transform(OpQuadPattern opQuadPattern) {
    // The internal representation is (graph, BGP)
    BasicPattern bgp2 = NodeTransformLib.transform(transform, opQuadPattern.getBasicPattern());
    Node g2 = opQuadPattern.getGraphNode();
    g2 = transform.apply(g2);
    if (g2 == opQuadPattern.getGraphNode() && bgp2 == opQuadPattern.getBasicPattern())
        return super.transform(opQuadPattern);
    return new OpQuadPattern(g2, bgp2);
}
Also used : Node(org.apache.jena.graph.Node) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 4 with BasicPattern

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

the class TransformReorder method transform.

/**
	 * Transforms BGPs with the reordering
	 */
@Override
public Op transform(OpBGP opBGP) {
    BasicPattern pattern = opBGP.getPattern();
    if (pattern.size() < 2)
        return opBGP;
    BasicPattern pattern2 = reorder.reorder(pattern);
    return new OpBGP(pattern2);
}
Also used : OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 5 with BasicPattern

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

the class TransformMergeBGPs method transform.

@Override
public Op transform(OpJoin opJoin, Op left, Op right) {
    BasicPattern p1 = asBGP(left);
    BasicPattern p2 = asBGP(right);
    if (p1 != null && p2 != null) {
        BasicPattern p = merge(p1, p2);
        return new OpBGP(p);
    }
    return super.transform(opJoin, left, right);
}
Also used : OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Aggregations

BasicPattern (org.apache.jena.sparql.core.BasicPattern)44 Node (org.apache.jena.graph.Node)15 Triple (org.apache.jena.graph.Triple)13 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)13 Op (org.apache.jena.sparql.algebra.Op)11 Test (org.junit.Test)11 Var (org.apache.jena.sparql.core.Var)5 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)5 Binding (org.apache.jena.sparql.engine.binding.Binding)5 ArrayList (java.util.ArrayList)4 BaseTest (org.apache.jena.atlas.junit.BaseTest)4 OpQuadPattern (org.apache.jena.sparql.algebra.op.OpQuadPattern)4 Quad (org.apache.jena.sparql.core.Quad)4 SocketException (java.net.SocketException)3 HashMap (java.util.HashMap)3 ConnectTimeoutException (org.apache.http.conn.ConnectTimeoutException)3 OpService (org.apache.jena.sparql.algebra.op.OpService)3 QueryExceptionHTTP (org.apache.jena.sparql.engine.http.QueryExceptionHTTP)3 Context (org.apache.jena.sparql.util.Context)3 IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)2