use of org.eclipse.rdf4j.query.algebra.ValueExpr 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;
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class TupleExprBuilder method createTupleExprForNegatedPropertySet.
private TupleExpr createTupleExprForNegatedPropertySet(NegatedPropertySet nps, int index) {
Var subjVar = nps.getSubjectVar();
Var predVar = createAnonVar();
ValueExpr filterCondition = null;
ValueExpr filterConditionInverse = null;
// build (inverted) filter conditions for each negated path element.
for (PropertySetElem elem : nps.getPropertySetElems()) {
ValueConstant predicate = elem.getPredicate();
if (elem.isInverse()) {
Compare compare = new Compare(predVar, predicate, CompareOp.NE);
if (filterConditionInverse == null) {
filterConditionInverse = compare;
} else {
filterConditionInverse = new And(compare, filterConditionInverse);
}
} else {
Compare compare = new Compare(predVar, predicate, CompareOp.NE);
if (filterCondition == null) {
filterCondition = compare;
} else {
filterCondition = new And(compare, filterCondition);
}
}
}
TupleExpr patternMatch = null;
// one item)
if (filterCondition != null) {
for (ValueExpr objVar : nps.getObjectList()) {
if (patternMatch == null) {
patternMatch = new StatementPattern(nps.getScope(), subjVar, predVar, (Var) objVar, nps.getContextVar());
} else {
patternMatch = new Join(new StatementPattern(nps.getScope(), subjVar, predVar, (Var) objVar, nps.getContextVar()), patternMatch);
}
}
}
TupleExpr patternMatchInverse = null;
// one item):
if (filterConditionInverse != null) {
for (ValueExpr objVar : nps.getObjectList()) {
if (patternMatchInverse == null) {
patternMatchInverse = new StatementPattern(nps.getScope(), (Var) objVar, predVar, subjVar, nps.getContextVar());
} else {
patternMatchInverse = new Join(new StatementPattern(nps.getScope(), (Var) objVar, predVar, subjVar, nps.getContextVar()), patternMatchInverse);
}
}
}
TupleExpr completeMatch = null;
if (patternMatch != null) {
completeMatch = new Filter(patternMatch, filterCondition);
}
if (patternMatchInverse != null) {
if (completeMatch == null) {
completeMatch = new Filter(patternMatchInverse, filterConditionInverse);
} else {
completeMatch = new Union(new Filter(patternMatchInverse, filterConditionInverse), completeMatch);
}
}
return completeMatch;
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class TupleExprBuilder method visit.
@Override
public Compare visit(ASTCompare 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 Compare(leftArg, rightArg, node.getOperator());
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class TupleExprBuilder method visit.
@Override
public Object visit(ASTAnd 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 And(leftArg, rightArg);
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class TupleExprBuilder method visit.
@Override
public Object visit(ASTLangMatches 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 LangMatches(leftArg, rightArg);
}
Aggregations