Search in sources :

Example 21 with ValueExpr

use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public Object visit(ASTConstraint node, Object data) throws VisitorException {
    ValueExpr valueExpr = (ValueExpr) super.visit(node, null);
    graphPattern.addConstraint(valueExpr);
    return valueExpr;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr)

Example 22 with ValueExpr

use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public Or visit(ASTOr node, Object data) throws VisitorException {
    ValueExpr leftArg = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
    ValueExpr rightArg = (ValueExpr) node.jjtGetChild(1).jjtAccept(this, null);
    return new Or(leftArg, rightArg);
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) Or(org.eclipse.rdf4j.query.algebra.Or)

Example 23 with ValueExpr

use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public MathExpr visit(ASTMath node, Object data) throws VisitorException {
    ValueExpr leftArg = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
    ValueExpr rightArg = (ValueExpr) node.jjtGetChild(1).jjtAccept(this, null);
    return new MathExpr(leftArg, rightArg, node.getOperator());
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) MathExpr(org.eclipse.rdf4j.query.algebra.MathExpr)

Example 24 with ValueExpr

use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.

the class BasicGroup method filteredTuple.

private TupleExpr filteredTuple(TupleExpr theExpr) {
    TupleExpr aExpr = theExpr;
    for (ValueExpr aValEx : mFilters) {
        Filter aFilter = new Filter();
        aFilter.setCondition(aValEx);
        aFilter.setArg(aExpr);
        aExpr = aFilter;
    }
    return aExpr;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) Filter(org.eclipse.rdf4j.query.algebra.Filter) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Example 25 with ValueExpr

use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.

the class GraphPattern method buildTupleExpr.

/**
 * Builds a combined tuple expression from the tuple expressions and constraints in this graph pattern.
 *
 * @return A tuple expression for this graph pattern.
 */
public TupleExpr buildTupleExpr() {
    TupleExpr result;
    if (requiredTEs.isEmpty()) {
        result = new SingletonSet();
    } else {
        result = requiredTEs.get(0);
        for (int i = 1; i < requiredTEs.size(); i++) {
            TupleExpr te = requiredTEs.get(i);
            // if (containsProjection(te) || containsProjection(result))
            // {
            // result = new BottomUpJoin(result, te);
            // }
            // else {
            result = new Join(result, te);
        // }
        }
    }
    for (Map.Entry<TupleExpr, List<ValueExpr>> entry : optionalTEs) {
        List<ValueExpr> constraints = entry.getValue();
        if (constraints != null && !constraints.isEmpty()) {
            ValueExpr condition = constraints.get(0);
            for (int i = 1; i < constraints.size(); i++) {
                condition = new And(condition, constraints.get(i));
            }
            result = new LeftJoin(result, entry.getKey(), condition);
        } else {
            result = new LeftJoin(result, entry.getKey());
        }
    }
    for (ValueExpr constraint : constraints) {
        result = new Filter(result, constraint);
    }
    return result;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) LeftJoin(org.eclipse.rdf4j.query.algebra.LeftJoin) SingletonSet(org.eclipse.rdf4j.query.algebra.SingletonSet) Filter(org.eclipse.rdf4j.query.algebra.Filter) And(org.eclipse.rdf4j.query.algebra.And) LeftJoin(org.eclipse.rdf4j.query.algebra.LeftJoin) Join(org.eclipse.rdf4j.query.algebra.Join) ArrayList(java.util.ArrayList) List(java.util.List) AbstractMap(java.util.AbstractMap) Map(java.util.Map) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Aggregations

ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)55 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)19 Var (org.eclipse.rdf4j.query.algebra.Var)19 ASTValueExpr (org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr)14 ProjectionElemList (org.eclipse.rdf4j.query.algebra.ProjectionElemList)10 ArrayList (java.util.ArrayList)9 Extension (org.eclipse.rdf4j.query.algebra.Extension)9 ExtensionElem (org.eclipse.rdf4j.query.algebra.ExtensionElem)9 And (org.eclipse.rdf4j.query.algebra.And)7 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)7 Filter (org.eclipse.rdf4j.query.algebra.Filter)6 Projection (org.eclipse.rdf4j.query.algebra.Projection)6 ProjectionElem (org.eclipse.rdf4j.query.algebra.ProjectionElem)6 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)6 List (java.util.List)5 Compare (org.eclipse.rdf4j.query.algebra.Compare)5 MultiProjection (org.eclipse.rdf4j.query.algebra.MultiProjection)5 Reduced (org.eclipse.rdf4j.query.algebra.Reduced)5 BNodeGenerator (org.eclipse.rdf4j.query.algebra.BNodeGenerator)4 Distinct (org.eclipse.rdf4j.query.algebra.Distinct)4