Search in sources :

Example 1 with P_FixedLength

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

the class PathEngineSPARQL method doFixedLengthPath.

@Override
protected void doFixedLengthPath(Path pathStep, Node node, long fixedLength, Collection<Node> output) {
    // Not SPARQL
    if (fixedLength == 0) {
        output.add(node);
        return;
    }
    // P_Mod(path, count, count)
    // One step.
    Iterator<Node> iter = eval(pathStep, node);
    // Build a path for all remaining steps.
    long count2 = dec(fixedLength);
    P_FixedLength nextPath = new P_FixedLength(pathStep, count2);
    // Accumulate across everything from first step.
    for (; iter.hasNext(); ) {
        Node n2 = iter.next();
        Iterator<Node> iter2 = eval(nextPath, n2);
        fill(iter2, output);
    }
}
Also used : Node(org.apache.jena.graph.Node) P_FixedLength(org.apache.jena.sparql.path.P_FixedLength)

Example 2 with P_FixedLength

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

the class PathEngineN method doFixedLengthPath.

@Override
protected void doFixedLengthPath(Path pathStep, Node node, long fixedLength, Collection<Node> output) {
    if (fixedLength == 0) {
        output.add(node);
        return;
    }
    // P_Mod(path, count, count)
    // One step.
    Iterator<Node> iter = eval(pathStep, node);
    // Build a path for all remaining steps.
    long count2 = dec(fixedLength);
    P_FixedLength nextPath = new P_FixedLength(pathStep, count2);
    // Accumulate across everything from first step.
    for (; iter.hasNext(); ) {
        Node n2 = iter.next();
        Iterator<Node> iter2 = eval(nextPath, n2);
        fill(iter2, output);
    }
}
Also used : Node(org.apache.jena.graph.Node) P_FixedLength(org.apache.jena.sparql.path.P_FixedLength)

Aggregations

Node (org.apache.jena.graph.Node)2 P_FixedLength (org.apache.jena.sparql.path.P_FixedLength)2