Search in sources :

Example 1 with PathBlock

use of org.apache.jena.sparql.core.PathBlock in project jena by apache.

the class PathCompiler method reduce.

// Move to AlgebraCompiler and have a per-transaction scoped var generator 
// ---- Syntax-based
/** Simplify : turns constructs in simple triples and simpler TriplePaths where possible */
public PathBlock reduce(PathBlock pathBlock) {
    PathBlock x = new PathBlock();
    // No context during algebra generation time.
    //        VarAlloc varAlloc = VarAlloc.get(context, ARQConstants.sysVarAllocNamed) ;
    //        if ( varAlloc == null )
    //            // Panic
    //            throw new ARQInternalErrorException("No execution-scope allocator for variables") ;
    // Translate one into another.
    reduce(x, pathBlock, varAlloc);
    return x;
}
Also used : PathBlock(org.apache.jena.sparql.core.PathBlock)

Example 2 with PathBlock

use of org.apache.jena.sparql.core.PathBlock in project jena by apache.

the class PathCompiler method reduce.

// ---- Algebra-based transformation.
public PathBlock reduce(TriplePath triplePath) {
    PathBlock x = new PathBlock();
    reduce(x, varAlloc, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject());
    return x;
}
Also used : PathBlock(org.apache.jena.sparql.core.PathBlock)

Example 3 with PathBlock

use of org.apache.jena.sparql.core.PathBlock in project jena by apache.

the class PathCompiler method reduce.

public PathBlock reduce(Node start, Path path, Node finish) {
    PathBlock x = new PathBlock();
    reduce(x, varAlloc, start, path, finish);
    return x;
}
Also used : PathBlock(org.apache.jena.sparql.core.PathBlock)

Example 4 with PathBlock

use of org.apache.jena.sparql.core.PathBlock in project jena by apache.

the class FormatterElement method visit.

@Override
public void visit(ElementPathBlock el) {
    // Write path block - don't put in a final trailing "." 
    if (el.isEmpty()) {
        out.println("# Empty BGP");
        return;
    }
    // Split into BGP-path-BGP-...
    // where the BGPs may be empty.
    PathBlock pBlk = el.getPattern();
    BasicPattern bgp = new BasicPattern();
    // Has anything been output?
    boolean first = true;
    for (TriplePath tp : pBlk) {
        if (tp.isTriple()) {
            bgp.add(tp.asTriple());
            continue;
        }
        if (!bgp.isEmpty()) {
            if (!first)
                out.println(" .");
            flush(bgp);
            first = false;
        }
        if (!first)
            out.println(" .");
        // Path
        printSubject(tp.getSubject());
        out.print(" ");
        PathWriter.write(out, tp.getPath(), context.getPrologue());
        out.print(" ");
        printObject(tp.getObject());
        first = false;
    }
    // Flush any stored triple patterns.
    if (!bgp.isEmpty()) {
        if (!first)
            out.println(" .");
        flush(bgp);
        first = false;
    }
}
Also used : BasicPattern(org.apache.jena.sparql.core.BasicPattern) TriplePath(org.apache.jena.sparql.core.TriplePath) PathBlock(org.apache.jena.sparql.core.PathBlock)

Aggregations

PathBlock (org.apache.jena.sparql.core.PathBlock)4 BasicPattern (org.apache.jena.sparql.core.BasicPattern)1 TriplePath (org.apache.jena.sparql.core.TriplePath)1