use of org.eclipse.rdf4j.query.algebra.TupleExpr in project rdf4j by eclipse.
the class GraphPattern method addOptionalTE.
public void addOptionalTE(GraphPattern gp) {
List<ValueExpr> constraints = gp.removeAllConstraints();
TupleExpr tupleExpr = gp.buildTupleExpr();
OptionalTupleExpr optTE;
if (constraints.isEmpty()) {
optTE = new OptionalTupleExpr(tupleExpr);
} else {
ValueExpr constraint = constraints.get(0);
for (int i = 1; i < constraints.size(); i++) {
constraint = new And(constraint, constraints.get(i));
}
optTE = new OptionalTupleExpr(tupleExpr, constraint);
}
optionalTEs.add(optTE);
}
use of org.eclipse.rdf4j.query.algebra.TupleExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public TupleExpr visit(ASTSelectQuery node, Object data) throws VisitorException {
TupleExpr tupleExpr;
ASTQueryBody queryBodyNode = node.getQueryBody();
if (queryBodyNode != null) {
// Build tuple expression for query body
tupleExpr = (TupleExpr) queryBodyNode.jjtAccept(this, null);
} else {
tupleExpr = new SingletonSet();
}
// Apply result ordering
ASTOrderBy orderByNode = node.getOrderBy();
if (orderByNode != null) {
List<OrderElem> orderElemements = (List<OrderElem>) orderByNode.jjtAccept(this, null);
tupleExpr = new Order(tupleExpr, orderElemements);
}
// Apply projection
tupleExpr = (TupleExpr) node.getSelectClause().jjtAccept(this, tupleExpr);
// process limit and offset clauses, if present.
ASTLimit limitNode = node.getLimit();
int limit = -1;
if (limitNode != null) {
limit = (Integer) limitNode.jjtAccept(this, null);
}
ASTOffset offsetNode = node.getOffset();
int offset = -1;
if (offsetNode != null) {
offset = (Integer) offsetNode.jjtAccept(this, null);
}
if (offset >= 1 || limit >= 0) {
tupleExpr = new Slice(tupleExpr, offset, limit);
}
return tupleExpr;
}
use of org.eclipse.rdf4j.query.algebra.TupleExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public CompareAny visit(ASTCompareAny node, Object data) throws VisitorException {
ValueExpr valueExpr = (ValueExpr) node.getLeftOperand().jjtAccept(this, null);
TupleExpr tupleExpr = (TupleExpr) node.getRightOperand().jjtAccept(this, null);
CompareOp op = node.getOperator().getValue();
return new CompareAny(valueExpr, tupleExpr, op);
}
use of org.eclipse.rdf4j.query.algebra.TupleExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public TupleExpr visit(ASTTupleIntersect node, Object data) throws VisitorException {
TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);
return new Intersection(leftArg, rightArg);
}
use of org.eclipse.rdf4j.query.algebra.TupleExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public In visit(ASTIn node, Object data) throws VisitorException {
ValueExpr valueExpr = (ValueExpr) node.getLeftOperand().jjtAccept(this, null);
TupleExpr tupleExpr = (TupleExpr) node.getRightOperand().jjtAccept(this, null);
return new In(valueExpr, tupleExpr);
}
Aggregations