Search in sources :

Example 16 with Var

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

the class ConstructorBuilder method getConstructVars.

/**
 * Gets the set of variables that are relevant for the constructor. This method accumulates all subject,
 * predicate and object variables from the supplied statement patterns, but ignores any context variables.
 */
private Set<Var> getConstructVars(Collection<StatementPattern> statementPatterns) {
    Set<Var> vars = new LinkedHashSet<Var>(statementPatterns.size() * 2);
    for (StatementPattern sp : statementPatterns) {
        vars.add(sp.getSubjectVar());
        vars.add(sp.getPredicateVar());
        vars.add(sp.getObjectVar());
    }
    return vars;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) StatementPattern(org.eclipse.rdf4j.query.algebra.StatementPattern) Var(org.eclipse.rdf4j.query.algebra.Var)

Example 17 with Var

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

the class GroupBuilder method valueToVar.

public static Var valueToVar(Value theValue) {
    Var aVar = new Var("var" + cnt++, theValue);
    aVar.setAnonymous(true);
    return aVar;
}
Also used : Var(org.eclipse.rdf4j.query.algebra.Var)

Example 18 with Var

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

the class GroupBuilder method filter.

public GroupBuilder<T, E> filter(String theVar, Compare.CompareOp theOp, Value theValue) {
    Compare aComp = new Compare(new Var(theVar), new ValueConstant(theValue), theOp);
    mGroup.addFilter(aComp);
    return this;
}
Also used : Var(org.eclipse.rdf4j.query.algebra.Var) ValueConstant(org.eclipse.rdf4j.query.algebra.ValueConstant) Compare(org.eclipse.rdf4j.query.algebra.Compare)

Example 19 with Var

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

the class ContextCollector method meet.

/**
 * @inheritDoc
 */
@Override
public void meet(final Filter theFilter) throws Exception {
    theFilter.getArg().visit(this);
    if (mContexts.containsKey(theFilter.getArg())) {
        Var aCtx = mContexts.get(theFilter.getArg());
        mContexts.remove(theFilter.getArg());
        mContexts.put(theFilter, aCtx);
    }
}
Also used : Var(org.eclipse.rdf4j.query.algebra.Var)

Example 20 with Var

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

the class TupleExprBuilder method visit.

@Override
public Object visit(ASTPropertyListPath propListNode, Object data) throws VisitorException {
    ValueExpr subject = (ValueExpr) data;
    ValueExpr verbPath = (ValueExpr) propListNode.getVerb().jjtAccept(this, data);
    if (verbPath instanceof Var) {
        @SuppressWarnings("unchecked") List<ValueExpr> objectList = (List<ValueExpr>) propListNode.getObjectList().jjtAccept(this, null);
        Var subjVar = mapValueExprToVar(subject);
        Var predVar = mapValueExprToVar(verbPath);
        for (ValueExpr object : objectList) {
            Var objVar = mapValueExprToVar(object);
            graphPattern.addRequiredSP(subjVar, predVar, objVar);
        }
    } else {
    // path is a single IRI or a more complex path. handled by the
    // visitor.
    }
    ASTPropertyListPath nextPropList = propListNode.getNextPropertyList();
    if (nextPropList != null) {
        nextPropList.jjtAccept(this, subject);
    }
    return null;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) Var(org.eclipse.rdf4j.query.algebra.Var) List(java.util.List) ArrayList(java.util.ArrayList) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList)

Aggregations

Var (org.eclipse.rdf4j.query.algebra.Var)48 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)19 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)15 ArrayList (java.util.ArrayList)14 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)14 ProjectionElemList (org.eclipse.rdf4j.query.algebra.ProjectionElemList)13 Extension (org.eclipse.rdf4j.query.algebra.Extension)10 ExtensionElem (org.eclipse.rdf4j.query.algebra.ExtensionElem)10 ASTVar (org.eclipse.rdf4j.query.parser.serql.ast.ASTVar)8 List (java.util.List)7 ProjectionElem (org.eclipse.rdf4j.query.algebra.ProjectionElem)7 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)7 LinkedHashSet (java.util.LinkedHashSet)6 Projection (org.eclipse.rdf4j.query.algebra.Projection)6 MultiProjection (org.eclipse.rdf4j.query.algebra.MultiProjection)5 Reduced (org.eclipse.rdf4j.query.algebra.Reduced)5 SameTerm (org.eclipse.rdf4j.query.algebra.SameTerm)5 Distinct (org.eclipse.rdf4j.query.algebra.Distinct)4 Filter (org.eclipse.rdf4j.query.algebra.Filter)4 BindingSet (org.eclipse.rdf4j.query.BindingSet)3