Search in sources :

Example 6 with SingletonSet

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

the class TupleExprBuilder method visit.

@Override
public TupleExpr visit(ASTDescribe node, Object data) throws VisitorException {
    TupleExpr tupleExpr = (TupleExpr) data;
    if (tupleExpr == null) {
        tupleExpr = new SingletonSet();
    }
    Extension e = new Extension();
    ProjectionElemList projectionElements = new ProjectionElemList();
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        ValueExpr resource = (ValueExpr) node.jjtGetChild(i).jjtAccept(this, null);
        if (resource instanceof Var) {
            projectionElements.addElement(new ProjectionElem(((Var) resource).getName()));
        } else {
            String alias = "_describe_" + UUID.randomUUID().toString().replaceAll("-", "_");
            ExtensionElem elem = new ExtensionElem(resource, alias);
            e.addElement(elem);
            projectionElements.addElement(new ProjectionElem(alias));
        }
    }
    if (!e.getElements().isEmpty()) {
        e.setArg(tupleExpr);
        tupleExpr = e;
    }
    Projection p = new Projection(tupleExpr, projectionElements);
    return new DescribeOperator(p);
}
Also used : Extension(org.eclipse.rdf4j.query.algebra.Extension) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList) ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) SingletonSet(org.eclipse.rdf4j.query.algebra.SingletonSet) Var(org.eclipse.rdf4j.query.algebra.Var) DescribeOperator(org.eclipse.rdf4j.query.algebra.DescribeOperator) ExtensionElem(org.eclipse.rdf4j.query.algebra.ExtensionElem) Projection(org.eclipse.rdf4j.query.algebra.Projection) MultiProjection(org.eclipse.rdf4j.query.algebra.MultiProjection) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr) ProjectionElem(org.eclipse.rdf4j.query.algebra.ProjectionElem)

Aggregations

SingletonSet (org.eclipse.rdf4j.query.algebra.SingletonSet)6 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ProjectionElemList (org.eclipse.rdf4j.query.algebra.ProjectionElemList)3 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)3 Order (org.eclipse.rdf4j.query.algebra.Order)2 OrderElem (org.eclipse.rdf4j.query.algebra.OrderElem)2 Service (org.eclipse.rdf4j.query.algebra.Service)2 Slice (org.eclipse.rdf4j.query.algebra.Slice)2 ASTInList (org.eclipse.rdf4j.query.parser.serql.ast.ASTInList)2 ASTLimit (org.eclipse.rdf4j.query.parser.serql.ast.ASTLimit)2 ASTOffset (org.eclipse.rdf4j.query.parser.serql.ast.ASTOffset)2 ASTOrderBy (org.eclipse.rdf4j.query.parser.serql.ast.ASTOrderBy)2 AbstractMap (java.util.AbstractMap)1 Map (java.util.Map)1 And (org.eclipse.rdf4j.query.algebra.And)1 DescribeOperator (org.eclipse.rdf4j.query.algebra.DescribeOperator)1 Extension (org.eclipse.rdf4j.query.algebra.Extension)1 ExtensionElem (org.eclipse.rdf4j.query.algebra.ExtensionElem)1