use of org.apache.jena.sparql.path.Path in project jena by apache.
the class PathEngineN method doSeq.
@Override
protected void doSeq(Path pathStepLeft, Path pathStepRight, Node node, Collection<Node> output) {
Path part1 = forwardMode ? pathStepLeft : pathStepRight;
Path part2 = forwardMode ? pathStepRight : pathStepLeft;
// Feed one side into the other
Iter<Node> iter = eval(part1, node);
iter.forEachRemaining((n) -> eval(part2, n, output));
}
use of org.apache.jena.sparql.path.Path in project jena by apache.
the class PathEngineN method doMultiLengthPath.
@Override
protected void doMultiLengthPath(Path pathStep, Node node, long min1, long max1, Collection<Node> output) {
if (min1 == P_Mod.UNSET)
// {,N}
min1 = 0;
if (min1 == 0)
output.add(node);
if (max1 == 0)
return;
// The next step
long min2 = dec(min1);
long max2 = dec(max1);
// TODO Rewrite
Path p1 = pathStep;
Path p2 = new P_Mod(pathStep, min2, max2);
if (!forwardMode) {
// Reverse order. Do the second bit first.
Path tmp = p1;
p1 = p2;
p2 = tmp;
// This forces execution to be in the order that it's written, when
// working backwards.
// {N,*} is {*} then {N} backwards != do {N} then do {*} as
// cardinality of the
// two operations is different.
}
// ****
// One step.
Iterator<Node> iter = eval(p1, node);
// Moved on one step
for (; iter.hasNext(); ) {
Node n2 = iter.next();
Iterator<Node> iter2 = eval(p2, n2);
fill(iter2, output);
}
// If no matches, will not call eval and we drop out.
}
use of org.apache.jena.sparql.path.Path in project jena by apache.
the class WhereClauseTest method testAddOptionalTriplePath.
@ContractTest
public void testAddOptionalTriplePath() {
WhereClause<?> whereClause = getProducer().newInstance();
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
AbstractQueryBuilder<?> builder = whereClause.addOptional(new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three")));
assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("urn:test:two") + "/" + uri("urn:test:dos") + SPACE + uri("three") + OPT_SPACE + CLOSE_CURLY, builder.buildString());
}
use of org.apache.jena.sparql.path.Path in project jena by apache.
the class WhereClauseTest method testAddOptionalObjectsWithPath.
@ContractTest
public void testAddOptionalObjectsWithPath() {
WhereClause<?> whereClause = getProducer().newInstance();
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
AbstractQueryBuilder<?> builder = whereClause.addOptional(NodeFactory.createURI("one"), path, NodeFactory.createURI("three"));
assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("urn:test:two") + "/" + uri("urn:test:dos") + SPACE + uri("three") + OPT_SPACE + CLOSE_CURLY, builder.buildString());
}
use of org.apache.jena.sparql.path.Path in project jena by apache.
the class TestPathPF method path_pf_00.
@Test
public void path_pf_00() {
Path path = SSE.parsePath("(link rdfs:member)");
eval(graph1, node0, path, new Node[] {});
}
Aggregations