Search in sources :

Example 6 with And

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

the class QueryModelBuilder method visit.

@Override
public ValueExpr visit(ASTAnd node, Object data) throws VisitorException {
    Iterator<ASTBooleanExpr> iter = node.getOperandList().iterator();
    ValueExpr result = (ValueExpr) iter.next().jjtAccept(this, null);
    while (iter.hasNext()) {
        ValueExpr operand = (ValueExpr) iter.next().jjtAccept(this, null);
        result = new And(result, operand);
    }
    return result;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ASTValueExpr(org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr) ASTBooleanExpr(org.eclipse.rdf4j.query.parser.serql.ast.ASTBooleanExpr) ASTAnd(org.eclipse.rdf4j.query.parser.serql.ast.ASTAnd) And(org.eclipse.rdf4j.query.algebra.And)

Example 7 with And

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

the class BasicGroup method filtersAsAnd.

private ValueExpr filtersAsAnd() {
    ValueExpr aExpr = null;
    for (ValueExpr aValEx : mFilters) {
        if (aExpr == null) {
            aExpr = aValEx;
        } else {
            And aAnd = new And();
            aAnd.setLeftArg(aValEx);
            aAnd.setRightArg(aExpr);
            aExpr = aAnd;
        }
    }
    return aExpr;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) And(org.eclipse.rdf4j.query.algebra.And)

Example 8 with And

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

the class AbstractQueryBuilder method groupAsJoin.

private TupleExpr groupAsJoin(List<Group> theList) {
    BinaryTupleOperator aJoin = new Join();
    Filter aFilter = null;
    for (Group aGroup : theList) {
        TupleExpr aExpr = aGroup.expr();
        if (aExpr == null) {
            continue;
        }
        if (aExpr instanceof Filter && (((Filter) aExpr).getArg() == null || ((Filter) aExpr).getArg() instanceof EmptySet)) {
            if (aFilter == null) {
                aFilter = (Filter) aExpr;
            } else {
                // if we already have a filter w/ an empty arg, let's And the
                // conditions together.
                aFilter.setCondition(new And(aFilter.getCondition(), ((Filter) aExpr).getCondition()));
            }
            continue;
        }
        if (aFilter != null) {
            aFilter.setArg(aExpr);
            aExpr = aFilter;
            aFilter = null;
        }
        if (aGroup.isOptional()) {
            LeftJoin lj = new LeftJoin();
            TupleExpr aLeft = joinOrExpr(aJoin);
            if (aLeft != null) {
                lj.setLeftArg(aLeft);
                lj.setRightArg(aExpr);
                aJoin = lj;
                continue;
            }
        }
        if (aJoin.getLeftArg() == null) {
            aJoin.setLeftArg(aExpr);
        } else if (aJoin.getRightArg() == null) {
            aJoin.setRightArg(aExpr);
        } else {
            Join aNewJoin = new Join();
            aNewJoin.setLeftArg(aJoin);
            aNewJoin.setRightArg(aExpr);
            aJoin = aNewJoin;
        }
    }
    TupleExpr aExpr = joinOrExpr(aJoin);
    if (aFilter != null) {
        aFilter.setArg(aExpr);
        aExpr = aFilter;
    }
    return aExpr;
}
Also used : LeftJoin(org.eclipse.rdf4j.query.algebra.LeftJoin) Filter(org.eclipse.rdf4j.query.algebra.Filter) And(org.eclipse.rdf4j.query.algebra.And) BinaryTupleOperator(org.eclipse.rdf4j.query.algebra.BinaryTupleOperator) EmptySet(org.eclipse.rdf4j.query.algebra.EmptySet) LeftJoin(org.eclipse.rdf4j.query.algebra.LeftJoin) Join(org.eclipse.rdf4j.query.algebra.Join) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Aggregations

And (org.eclipse.rdf4j.query.algebra.And)8 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)7 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)4 Filter (org.eclipse.rdf4j.query.algebra.Filter)3 Join (org.eclipse.rdf4j.query.algebra.Join)3 Compare (org.eclipse.rdf4j.query.algebra.Compare)2 LeftJoin (org.eclipse.rdf4j.query.algebra.LeftJoin)2 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)2 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 BinaryTupleOperator (org.eclipse.rdf4j.query.algebra.BinaryTupleOperator)1 EmptySet (org.eclipse.rdf4j.query.algebra.EmptySet)1 SingletonSet (org.eclipse.rdf4j.query.algebra.SingletonSet)1 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)1 Union (org.eclipse.rdf4j.query.algebra.Union)1 Var (org.eclipse.rdf4j.query.algebra.Var)1 ASTAnd (org.eclipse.rdf4j.query.parser.serql.ast.ASTAnd)1 ASTBooleanExpr (org.eclipse.rdf4j.query.parser.serql.ast.ASTBooleanExpr)1