Search in sources :

Example 16 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestServiceSetup method testNumericTimeout.

@Test
public void testNumericTimeout() {
    BasicPattern basicPattern = new BasicPattern();
    basicPattern.add(Triple.ANY);
    Node serviceNode = NodeFactory.createURI(SERVICE);
    OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false);
    Context context = new Context();
    ARQ.setNormalMode(context);
    context.set(Service.httpQueryTimeout, 10);
    try {
        Service.exec(opService, context);
        Assert.fail("Expected QueryExceptionHTTP");
    } catch (QueryExceptionHTTP expected) {
        Throwable thrown = expected.getCause();
        if (thrown instanceof SocketException || thrown instanceof HttpConnectTimeoutException || thrown instanceof UnknownHostException) {
        // expected
        } else {
            Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
        }
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SocketException(java.net.SocketException) UnknownHostException(java.net.UnknownHostException) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) OpService(org.apache.jena.sparql.algebra.op.OpService) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) HttpConnectTimeoutException(java.net.http.HttpConnectTimeoutException) Test(org.junit.Test)

Example 17 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestSPARQLStarParse method build.

private static Triple build(String string) {
    Query query = parse(string);
    Op op = Algebra.compile(query);
    BasicPattern bgp = ((OpBGP) op).getPattern();
    assertEquals(1, bgp.size());
    Triple t = bgp.get(0);
    return t;
}
Also used : Triple(org.apache.jena.graph.Triple) Op(org.apache.jena.sparql.algebra.Op) OpAsQuery(org.apache.jena.sparql.algebra.OpAsQuery) Query(org.apache.jena.query.Query) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 18 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class PathLib method flush.

private static Op flush(BasicPattern bp, Op op) {
    if (bp == null || bp.isEmpty())
        return op;
    OpBGP opBGP = new OpBGP(bp);
    op = OpSequence.create(op, opBGP);
    return op;
}
Also used : OpBGP(org.apache.jena.sparql.algebra.op.OpBGP)

Example 19 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestBlankNodeBinary method bNodeSPARQL_Query_2.

@Test
public void bNodeSPARQL_Query_2() {
    String qs = "SELECT * { ?s ?p <_:BCD>}";
    Query query = QueryFactory.create(qs);
    Op op = Algebra.compile(query);
    BasicPattern bp = ((OpBGP) op).getPattern();
    Triple t = bp.get(0);
    assertEquals("BCD", t.getObject().getBlankNodeLabel());
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern) Test(org.junit.Test)

Example 20 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class tdbreorder method main.

public static void main(String... args) {
    if (args.length != 2) {
        System.err.println("Usage: PATTERN STATS");
        System.exit(1);
    }
    LogCtl.enable(StatsMatcher.class);
    LogCtl.enable(ReorderTransformationSubstitution.class);
    if (args.length != 2) {
        System.err.println("Usage: op stats");
        System.exit(1);
    }
    String pattern = args[0];
    String statsFile = args[1];
    Op op = SSE.readOp(pattern);
    BasicPattern bgp;
    if (op instanceof OpQuadPattern) {
        bgp = ((OpQuadPattern) op).getBasicPattern();
    } else if (op instanceof OpBGP) {
        bgp = ((OpBGP) op).getPattern();
    } else {
        System.err.println("Not a quad or triple pattern");
        System.exit(2);
        bgp = null;
    }
    ReorderTransformation reorder = chooseReorder(statsFile);
    // ReorderTransformation reorder = ReorderLib.fixed() ;
    BasicPattern bgp2 = reorder.reorder(bgp);
    System.out.println();
    print(bgp);
    System.out.println();
    System.out.println(" ======== >>>>>>>>");
    print(bgp2);
    System.out.println();
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpQuadPattern(org.apache.jena.sparql.algebra.op.OpQuadPattern) ReorderTransformation(org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Aggregations

OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)21 BasicPattern (org.apache.jena.sparql.core.BasicPattern)19 Op (org.apache.jena.sparql.algebra.Op)11 Node (org.apache.jena.graph.Node)10 Triple (org.apache.jena.graph.Triple)9 Test (org.junit.Test)9 SocketException (java.net.SocketException)5 OpService (org.apache.jena.sparql.algebra.op.OpService)5 QueryExceptionHTTP (org.apache.jena.sparql.engine.http.QueryExceptionHTTP)5 Context (org.apache.jena.sparql.util.Context)5 Var (org.apache.jena.sparql.core.Var)4 ArrayList (java.util.ArrayList)3 ConnectTimeoutException (org.apache.http.conn.ConnectTimeoutException)3 Query (org.apache.jena.query.Query)3 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)3 Binding (org.apache.jena.sparql.engine.binding.Binding)3 Expr (org.apache.jena.sparql.expr.Expr)3 ExprVar (org.apache.jena.sparql.expr.ExprVar)3 UnknownHostException (java.net.UnknownHostException)2 HttpConnectTimeoutException (java.net.http.HttpConnectTimeoutException)2