Java Code Examples for org.eclipse.rdf4j.query.algebra.ValueExpr#visit()
The following examples show how to use
org.eclipse.rdf4j.query.algebra.ValueExpr#visit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void meet(ProjectionElem node) throws RDFHandlerException { ValueExpr valueExpr = null; if (inlineBindings != null) { String varName = node.getSourceName(); valueExpr = inlineBindings.getValueExpr(varName); } Resource targetVar = getVar(node.getTargetName()); listEntry(targetVar); if (valueExpr != null && !(valueExpr instanceof Var)) { Resource currentSubj = subject; subject = valueFactory.createBNode(); handler.handleStatement(valueFactory.createStatement(targetVar, SP.EXPRESSION_PROPERTY, subject)); valueExpr.visit(new ExtensionVisitor()); subject = currentSubj; } }
Example 2
Source File: SparqlValueExprRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @inheritDoc */ @Override public void meet(FunctionCall theOp) throws Exception { mBuffer.append("<").append(theOp.getURI()).append(">("); boolean aFirst = true; for (ValueExpr aArg : theOp.getArgs()) { if (!aFirst) { mBuffer.append(", "); } else { aFirst = false; } aArg.visit(this); } mBuffer.append(")"); }
Example 3
Source File: SerqlValueExprRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @inheritDoc */ @Override public void meet(FunctionCall theOp) throws Exception { mBuffer.append(theOp.getURI()).append("("); boolean aFirst = true; for (ValueExpr aArg : theOp.getArgs()) { if (!aFirst) { mBuffer.append(", "); } else { aFirst = false; } aArg.visit(this); } mBuffer.append(")"); }
Example 4
Source File: CopyRule.java From rya with Apache License 2.0 | 6 votes |
/** * If we can't evaluate one half of an AND by looking at this statement alone, it might * turn out to be true in the full graph, so the statement is relevant if the half we * can evaluate is true. If we can't evaluate either half, then the AND is useless and * we must assume the statement is relevant. Otherwise, keep both sides. */ @Override public void meet(final And expr) { final ValueExpr left = expr.getLeftArg(); final ValueExpr right = expr.getRightArg(); left.visit(this); right.visit(this); final QueryModelNode parent = expr.getParentNode(); if (trivialCondition(left)) { if (trivialCondition(right)) { // Both sides are trivial; replace whole node parent.replaceChildNode(expr, null); } else { // Left side trivial, right side good; replace node with right arg parent.replaceChildNode(expr, right); } } else if (trivialCondition(right)) { // Left side good, right side trivial; replace node with left arg parent.replaceChildNode(expr, left); } // Otherwise, both sides are useful }
Example 5
Source File: SPARQLValueExprRenderer.java From semagrow with Apache License 2.0 | 6 votes |
/** * @inheritDoc */ @Override public void meet(FunctionCall theOp) throws Exception { mBuffer.append("<").append(theOp.getURI()).append(">("); boolean aFirst = true; for (ValueExpr aArg : theOp.getArgs()) { if (!aFirst) { mBuffer.append(", "); } else { aFirst = false; } aArg.visit(this); } mBuffer.append(")"); }
Example 6
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void meet(ValueExpr node) throws RDFHandlerException { predicate = SP.EXPRESSION_PROPERTY; ListContext ctx = save(); list = null; node.visit(this); restore(ctx); }
Example 7
Source File: SerqlValueExprRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Return the rendering of the ValueExpr object * * @param theExpr the expression to render * @return the rendering * @throws Exception if there is an error while rendering */ public String render(ValueExpr theExpr) throws Exception { reset(); theExpr.visit(this); return mBuffer.toString(); }
Example 8
Source File: CopyRule.java From rya with Apache License 2.0 | 5 votes |
/** * Detect that a condition is trivial and can be replaced. This may mean it is always * true, or that it contains undefined variables and therefore we must assume it is * true or risk missing relevant statements. * @param expr Condition to be evaluated * @return true if the condition is trivial */ private static boolean trivialCondition(final ValueExpr expr) { // If the expression is null or the constant "true": if (expr == null || expr.equals(TRUE)) { return true; } // If the expression contains undefined variables: final VarSearchVisitor visitor = new VarSearchVisitor(UNDEFINED_VAR.getName()); expr.visit(visitor); if (visitor.found) { return true; } // Otherwise, the condition is non-trivial. return false; }
Example 9
Source File: FilterOptimizer.java From CostFed with GNU Affero General Public License v3.0 | 4 votes |
public HashSet<String> findVars(ValueExpr expr) { vars = new HashSet<String>(); expr.visit(this); return vars; }
Example 10
Source File: FilterOptimizer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
public HashSet<String> findVars(ValueExpr expr) { vars = new HashSet<>(); expr.visit(this); return vars; }
Example 11
Source File: SPARQLValueExprRenderer.java From semagrow with Apache License 2.0 | 3 votes |
/** * Return the rendering of the ValueExpr object * * @param theExpr * the expression to render * @return the rendering * @throws Exception * if there is an error while rendering */ public String render(ValueExpr theExpr) throws Exception { theExpr.visit(this); return mBuffer.toString(); }
Example 12
Source File: SparqlValueExprRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Return the rendering of the ValueExpr object * * @param theExpr the expression to render * @return the rendering * @throws Exception if there is an error while rendering */ public String render(ValueExpr theExpr) throws Exception { theExpr.visit(this); return mBuffer.toString(); }