public GroupBuilder<T, E> sameTerm(ValueExpr theLeft, ValueExpr theRight) { return filter(new SameTerm(theLeft, theRight)); }
/** * @inheritDoc */ @Override public void meet(SameTerm theOp) throws Exception { mBuffer.append(" sameTerm("); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(SameTerm theOp) throws Exception { mBuffer.append(" sameTerm("); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
public GroupBuilder<T, E> sameTerm(ValueExpr theLeft, ValueExpr theRight) { return filter(new SameTerm(theLeft, theRight)); }
/** * @inheritDoc */ @Override public void meet(SameTerm theOp) throws Exception { mBuffer.append(" sameTerm("); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
public GroupBuilder<T, E> sameTerm(ValueExpr theLeft, ValueExpr theRight) { return filter(new SameTerm(theLeft, theRight)); }
public Value evaluate(SameTerm node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); return BooleanLiteral.valueOf(leftVal != null && leftVal.equals(rightVal)); }
@Override public List<Var> visit(ASTNode node, Object data) throws VisitorException { List<Var> nodeVars = new ArrayList<Var>(); for (ASTNodeElem nodeElem : node.getNodeElemList()) { Var nodeVar = (Var)nodeElem.jjtAccept(this, null); nodeVars.add(nodeVar); } // Create any implicit unequalities for (int i = 0; i < nodeVars.size() - 1; i++) { Var var1 = nodeVars.get(i); for (int j = i + 1; j < nodeVars.size(); j++) { Var var2 = nodeVars.get(j); // At least one of the variables should be non-constant // for the unequality to make any sense: if (!var1.hasValue() || !var2.hasValue()) { graphPattern.addConstraint(new Not(new SameTerm(var1, var2))); } } } return nodeVars; }
public Value evaluate(SameTerm node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); return BooleanLiteral.valueOf(leftVal != null && leftVal.equals(rightVal)); }
@Override public List<Var> visit(ASTNode node, Object data) throws VisitorException { List<Var> nodeVars = new ArrayList<>(); for (ASTNodeElem nodeElem : node.getNodeElemList()) { Var nodeVar = (Var)nodeElem.jjtAccept(this, null); nodeVars.add(nodeVar); } // Create any implicit unequalities for (int i = 0; i < nodeVars.size() - 1; i++) { Var var1 = nodeVars.get(i); for (int j = i + 1; j < nodeVars.size(); j++) { Var var2 = nodeVars.get(j); // At least one of the variables should be non-constant // for the unequality to make any sense: if (!var1.hasValue() || !var2.hasValue()) { graphPattern.addConstraint(new Not(new SameTerm(var1, var2))); } } } return nodeVars; }
/** * Evaluate if the left and right arguments of the {@link SameTerm} node are equal * @param node the node to evaluate * @param bindings the set of named value bindings * @return * @throws ValueExprEvaluationException * @throws QueryEvaluationException */ private Value evaluate(SameTerm node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); return BooleanLiteral.valueOf(leftVal != null && leftVal.equals(rightVal)); }
@Override public List<Var> visit(ASTNode node, Object data) throws VisitorException { List<Var> nodeVars = new ArrayList<Var>(); for (ASTNodeElem nodeElem : node.getNodeElemList()) { Var nodeVar = (Var)nodeElem.jjtAccept(this, null); nodeVars.add(nodeVar); } // Create any implicit unequalities for (int i = 0; i < nodeVars.size() - 1; i++) { Var var1 = nodeVars.get(i); for (int j = i + 1; j < nodeVars.size(); j++) { Var var2 = nodeVars.get(j); // At least one of the variables should be non-constant // for the unequality to make any sense: if (!var1.hasValue() || !var2.hasValue()) { graphPattern.addConstraint(new Not(new SameTerm(var1, var2))); } } } return nodeVars; }
theOp.getLeftArg().visit(this); mBuffer.append(" = "); theOp.getRightArg().visit(this); mBuffer.append(")"); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")");
@Override public SameTerm visit(ASTSameTerm node, Object data) throws VisitorException { ValueExpr leftArg = (ValueExpr)node.getLeftOperand().jjtAccept(this, null); ValueExpr rightArg = (ValueExpr)node.getRightOperand().jjtAccept(this, null); return new SameTerm(leftArg, rightArg); }
theOp.getLeftArg().visit(this); mBuffer.append(" = "); theOp.getRightArg().visit(this); mBuffer.append(")"); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")");
@Override public SameTerm visit(ASTSameTerm 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 SameTerm(leftArg, rightArg); }
theOp.getLeftArg().visit(this); mBuffer.append(" = "); theOp.getRightArg().visit(this); mBuffer.append(")"); theOp.getLeftArg().visit(this); mBuffer.append(", "); theOp.getRightArg().visit(this); mBuffer.append(")");
@Override public SameTerm visit(ASTSameTerm 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 SameTerm(leftArg, rightArg); }
private List<StatementPattern> replaceSameTermVars(List<StatementPattern> statementPatterns, Set<SameTerm> sameTermConstraints) { if (sameTermConstraints != null) { for (SameTerm st : sameTermConstraints) { Var left = (Var)st.getLeftArg(); Var right = (Var)st.getRightArg(); for (StatementPattern sp : statementPatterns) { Var subj = sp.getSubjectVar(); Var obj = sp.getObjectVar(); if (subj.equals(left) || subj.equals(right)) { if (obj.equals(left) || obj.equals(right)) { sp.setObjectVar(subj); } } } } } return statementPatterns; }
@Override public SameTerm visit(ASTSameTerm node, Object data) throws VisitorException { ValueExpr leftArg = (ValueExpr)node.getLeftOperand().jjtAccept(this, null); ValueExpr rightArg = (ValueExpr)node.getRightOperand().jjtAccept(this, null); return new SameTerm(leftArg, rightArg); }