use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class OpTriple method asBGP.
public final OpBGP asBGP() {
if (opBGP == null) {
BasicPattern bp = new BasicPattern();
bp.add(getTriple());
opBGP = new OpBGP(bp);
}
return opBGP;
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class OpRewriterTest method testBGP.
@Test
public void testBGP() {
SecurityEvaluator securityEvaluator = new MockSecurityEvaluator(true, true, true, true, true, true);
rewriter = new OpRewriter(securityEvaluator, "http://example.com/dummy");
rewriter.visit(new OpBGP(BasicPattern.wrap(Arrays.asList(triples))));
Op op = rewriter.getResult();
Assert.assertTrue("Should have been an OpFilter", op instanceof OpFilter);
OpFilter filter = (OpFilter) op;
ExprList eLst = filter.getExprs();
Assert.assertEquals(1, eLst.size());
Assert.assertTrue("Should have been a SecuredFunction", eLst.get(0) instanceof SecuredFunction);
op = filter.getSubOp();
Assert.assertTrue("Should have been a OpBGP", op instanceof OpBGP);
BasicPattern basicPattern = ((OpBGP) op).getPattern();
Assert.assertEquals(3, basicPattern.size());
Triple t = basicPattern.get(0);
Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
Assert.assertEquals(RDF.type.asNode(), t.getPredicate());
Assert.assertEquals(NodeFactory.createURI("http://example.com/class"), t.getObject());
t = basicPattern.get(1);
Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
Assert.assertEquals(NodeFactory.createVariable("bar"), t.getObject());
t = basicPattern.get(2);
Assert.assertEquals(NodeFactory.createVariable("bar"), t.getSubject());
Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
Assert.assertEquals(NodeFactory.createVariable("baz"), t.getObject());
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class OpExecutorTDB1 method execute.
@Override
protected QueryIterator execute(OpQuadPattern quadPattern, QueryIterator input) {
if (!isForTDB)
return super.execute(quadPattern, input);
// DatasetGraph dg = execCxt.getDataset() ;
// if ( ! ( dg instanceof DatasetGraphTDB ) )
// throw new InternalErrorException("Not a TDB backed dataset in quad pattern execution") ;
DatasetGraphTDB ds = (DatasetGraphTDB) execCxt.getDataset();
BasicPattern bgp = quadPattern.getBasicPattern();
Node gn = quadPattern.getGraphNode();
return optimizeExecuteQuads(ds, input, gn, bgp, null, execCxt);
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class ReorderProcIndexes method reorder.
/** Return a new basic pattern with the same triples as the input,
* but ordered as per the index list of this reorder processor.
*/
@Override
public BasicPattern reorder(BasicPattern bgp) {
if (indexes.length != bgp.size()) {
String str = String.format("Expected size = %d : actual basic pattern size = %d", indexes.length, bgp.size());
Log.error(this, str);
throw new ARQException(str);
}
BasicPattern bgp2 = new BasicPattern();
for (int idx : indexes) {
Triple t = bgp.get(idx);
bgp2.add(t);
}
return bgp2;
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TestService method testStringTimeout2.
@Test
public void testStringTimeout2() {
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.queryTimeout, "10,10000");
try {
Service.exec(opService, context);
Assert.fail("Expected QueryExceptionHTTP");
} catch (QueryExceptionHTTP expected) {
Throwable thrown = expected.getCause();
if (thrown instanceof SocketException || thrown instanceof ConnectTimeoutException) {
// expected
} else {
Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
}
}
}
Aggregations