@Override public void meet(final FunctionCall call) { final URI fnUri = valueFactory.createURI(call.getURI()); final Var resultVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(fnUri, call.getArgs()); if (resultVar != null && resultVar.getName().equals(matchVar)) { addFilter(valueFactory.createURI(call.getURI()), extractArguments(matchVar, call)); if (call.getParentNode() instanceof Filter || call.getParentNode() instanceof And || call.getParentNode() instanceof LeftJoin) { call.replaceWith(new ValueConstant(valueFactory.createLiteral(true))); } else { throw new IllegalArgumentException("Query error: Found " + call + " as part of an expression that is too complex"); } } }
@Override public void meet(FunctionCall f) throws SailException { if(f.getURI().startsWith(GEOF.NAMESPACE)) { List<ValueExpr> args = f.getArgs(); if(args.size() != 2) { return; QueryModelNode parent = f.getParentNode(); if(parent instanceof ExtensionElem) { fVar = ((ExtensionElem)parent).getName(); spec.setRelation(f.getURI()); spec.setFunctionParent(parent); spec.setQueryGeometry(qshape);
private Value toValue(FunctionCall node) { String funcName = node.getURI(); IRI funcUri = wellKnownFunctions.apply(funcName); if (funcUri == null) { funcUri = valueFactory.createIRI(funcName); } return funcUri; }
private FunctionCall createFunctionCall(String uri, SimpleNode node, int minArgs, int maxArgs) throws VisitorException { FunctionCall functionCall = new FunctionCall(uri); int noOfArguments = node.jjtGetNumChildren(); if (noOfArguments > maxArgs || noOfArguments < minArgs) { throw new VisitorException( "unexpected number of arguments (" + noOfArguments + ") for function " + uri); } for (int i = 0; i < noOfArguments; i++) { Node argNode = node.jjtGetChild(i); functionCall.addArg((ValueExpr)argNode.jjtAccept(this, null)); } return functionCall; }
private Value[] extractArguments(final String matchName, final FunctionCall call) { final Value args[] = new Value[call.getArgs().size() - 1]; int argI = 0; for (int i = 0; i != call.getArgs().size(); ++i) { final ValueExpr arg = call.getArgs().get(i); if (argI == i && arg instanceof Var && matchName.equals(((Var)arg).getName())) { continue; } if (arg instanceof ValueConstant) { args[argI] = ((ValueConstant)arg).getValue(); } else if (arg instanceof Var && ((Var)arg).hasValue()) { args[argI] = ((Var)arg).getValue(); } else { throw new IllegalArgumentException("Query error: Found " + arg + ", expected a Literal, BNode or URI"); } ++argI; } return args; }
super.meet(functionCall); List<ValueExpr> args = functionCall.getArgs(); functionCall.replaceWith(new ValueConstant(value));
body = new Filter(body, new Compare(new FunctionCall( RR.STAR_SELECT_GRAPH.stringValue(), filterGraphVars), new Var("_const-" + UUID.randomUUID(), RDF.NIL), CompareOp.NE)); body = new Extension(body, new ExtensionElem(new FunctionCall( RR.STAR_SELECT_GRAPH.stringValue(), bindGraphVars), prefix));
public void addArgs(Iterable<ValueExpr> args) { for (ValueExpr arg : args) { addArg(arg); } }
@Override public void meet(FunctionCall f) throws SailException { if(GEOF.DISTANCE.stringValue().equals(f.getURI())) { List<ValueExpr> args = f.getArgs(); if(args.size() != 3) { return; URI units = getURI(args.get(2)); Literal dist = null; String distanceVar = null; QueryModelNode parent = f.getParentNode(); if(parent instanceof ExtensionElem) { distanceVar = ((ExtensionElem)parent).getName();
/** * Determines if the provided zero-arg function is a function that should * return a constant value for the entire query execution (e.g NOW()), or * if it should generate a new value for every call (e.g. RAND()). * * @param functionCall * a zero-arg function call. * @return <code>true<code> iff the provided function returns a constant value for the query execution, <code>false</code> * otherwise. */ private boolean isConstantZeroArgFunction(FunctionCall functionCall) { Function function = FunctionRegistry.getInstance().get(functionCall.getURI()).orElseThrow( () -> new QueryEvaluationException( "Unable to find function with the URI: " + functionCall.getURI())); // we treat constant functions as the 'regular case' and make // exceptions for specific SPARQL built-in functions that require // different treatment. if (function instanceof Rand || function instanceof UUID || function instanceof STRUUID) { return false; } return true; }
@Override public FunctionCall visit(ASTFunctionCall node, Object data) throws VisitorException { ValueConstant vc = (ValueConstant)node.getURI().jjtAccept(this, null); assert vc.getValue() instanceof IRI; FunctionCall functionCall = new FunctionCall(vc.getValue().toString()); for (ASTValueExpr argExpr : node.getArgList().getElements()) { functionCall.addArg((ValueExpr)argExpr.jjtAccept(this, null)); } return functionCall; }
@Override public void meet(FunctionCall node) throws RDFHandlerException { Resource currentSubj = subject; flushPendingStatement(); handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, toValue(node))); List<ValueExpr> args = node.getArgs(); for (int i = 0; i < args.size(); i++) { predicate = toArgProperty(i + 1); args.get(i).visit(this); } subject = currentSubj; predicate = null; }
expr = new FunctionCall(funcName, args);
public void addArgs(ValueExpr... args) { for (ValueExpr arg : args) { addArg(arg); } }
/** * Returns a PeriodicQueryNode for all {@link FunctionCall}s that represent PeriodicQueryNodes, otherwise * an empty Optional is returned. * @param functionCall - FunctionCall taken from a {@lin TupleExpr} * @param arg - TupleExpr that will be the argument of the PeriodicQueryNode if it is created * @return - Optional containing a PeriodicQueryNode if FunctionCall represents PeriodicQueryNode and empty Optional otherwise * @throws Exception */ public static Optional<PeriodicQueryNode> getPeriodicQueryNode(FunctionCall functionCall, TupleExpr arg) throws Exception { if (functionCall.getURI().equals(PeriodicQueryURI)) { return Optional.of(parseAndSetValues(functionCall.getArgs(), arg)); } return Optional.empty(); }
@Override public void meet(FunctionCall fc) throws RuntimeException { NativeFunction nf = NativeFunctionRegistry.getInstance().get(fc.getURI()); if (nf != null) { optypes.add(nf.getReturnType()); } }
@Override public Object visit(ASTFunctionCall node, Object data) throws VisitorException { ValueConstant uriNode = (ValueConstant)node.jjtGetChild(0).jjtAccept(this, null); IRI functionURI = (IRI)uriNode.getValue(); FunctionCall functionCall = new FunctionCall(functionURI.toString()); for (int i = 1; i < node.jjtGetNumChildren(); i++) { Node argNode = node.jjtGetChild(i); functionCall.addArg((ValueExpr)argNode.jjtAccept(this, null)); } return functionCall; }
return new Str(toValue(expr.getArg(0), md)); } else if (op == Ops.NUMCAST) { return new FunctionCall(toVar(expr.getArg(1), md).getValue().stringValue(), toValue(expr.getArg(0), md)); } else if (FUNCTION_OPS.containsKey(op)) { List<ValueExpr> args = new ArrayList<ValueExpr>(expr.getArgs().size()); args.add(toValue(e, md)); return new FunctionCall(FUNCTION_OPS.get(op), args); } else { throw new IllegalArgumentException(expr.toString());