Search in sources :

Example 1 with ASTPathExprTail

use of org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail in project rdf4j by eclipse.

the class QueryModelBuilder method visit.

@Override
public Object visit(ASTOptPathExprTail tailNode, Object data) throws VisitorException {
    List<Var> subjVars = (List<Var>) data;
    // Create new sub-graph pattern for optional path expressions
    graphPattern = new GraphPattern(graphPattern);
    // optional path expression tail
    tailNode.getOptionalTail().jjtAccept(this, subjVars);
    ASTWhere whereNode = tailNode.getWhereClause();
    if (whereNode != null) {
        // boolean contraint on optional path expression tail
        whereNode.jjtAccept(this, null);
    }
    graphPattern.getParent().addOptionalTE(graphPattern);
    graphPattern = graphPattern.getParent();
    ASTPathExprTail nextTailNode = tailNode.getNextTail();
    if (nextTailNode != null) {
        // branch after optional path expression tail
        nextTailNode.jjtAccept(this, subjVars);
    }
    return null;
}
Also used : ASTVar(org.eclipse.rdf4j.query.parser.serql.ast.ASTVar) Var(org.eclipse.rdf4j.query.algebra.Var) ASTWhere(org.eclipse.rdf4j.query.parser.serql.ast.ASTWhere) ASTInList(org.eclipse.rdf4j.query.parser.serql.ast.ASTInList) ArrayList(java.util.ArrayList) List(java.util.List) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList) ASTPathExprTail(org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail)

Example 2 with ASTPathExprTail

use of org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail in project rdf4j by eclipse.

the class QueryModelBuilder method visit.

@Override
public Object visit(ASTBasicPathExprTail tailNode, Object data) throws VisitorException {
    List<Var> subjVars = (List<Var>) data;
    Var predVar = (Var) tailNode.getEdge().jjtAccept(this, null);
    List<Var> objVars = (List<Var>) tailNode.getNode().jjtAccept(this, null);
    Var contextVar = graphPattern.getContextVar();
    StatementPattern.Scope spScope = graphPattern.getStatementPatternScope();
    for (Var subjVar : subjVars) {
        for (Var objVar : objVars) {
            StatementPattern sp = new StatementPattern(spScope, subjVar, predVar, objVar, contextVar);
            graphPattern.addRequiredTE(sp);
        }
    }
    // Process next tail segment
    ASTPathExprTail nextTailNode = tailNode.getNextTail();
    if (nextTailNode != null) {
        List<Var> joinVars = nextTailNode.isBranch() ? subjVars : objVars;
        nextTailNode.jjtAccept(this, joinVars);
    }
    return null;
}
Also used : StatementPattern(org.eclipse.rdf4j.query.algebra.StatementPattern) ASTVar(org.eclipse.rdf4j.query.parser.serql.ast.ASTVar) Var(org.eclipse.rdf4j.query.algebra.Var) ASTInList(org.eclipse.rdf4j.query.parser.serql.ast.ASTInList) ArrayList(java.util.ArrayList) List(java.util.List) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList) ASTPathExprTail(org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ProjectionElemList (org.eclipse.rdf4j.query.algebra.ProjectionElemList)2 Var (org.eclipse.rdf4j.query.algebra.Var)2 ASTInList (org.eclipse.rdf4j.query.parser.serql.ast.ASTInList)2 ASTPathExprTail (org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail)2 ASTVar (org.eclipse.rdf4j.query.parser.serql.ast.ASTVar)2 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)1 ASTWhere (org.eclipse.rdf4j.query.parser.serql.ast.ASTWhere)1