Search in sources :

Example 1 with P_Mod

use of org.apache.jena.sparql.path.P_Mod 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.
}
Also used : Path(org.apache.jena.sparql.path.Path) P_Mod(org.apache.jena.sparql.path.P_Mod) Node(org.apache.jena.graph.Node)

Example 2 with P_Mod

use of org.apache.jena.sparql.path.P_Mod in project jena by apache.

the class PathEngineSPARQL 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);
    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.
}
Also used : Path(org.apache.jena.sparql.path.Path) P_Mod(org.apache.jena.sparql.path.P_Mod) Node(org.apache.jena.graph.Node)

Aggregations

Node (org.apache.jena.graph.Node)2 P_Mod (org.apache.jena.sparql.path.P_Mod)2 Path (org.apache.jena.sparql.path.Path)2