MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _consume_function_call_expression

Function _consume_function_call_expression

src/ast/ast.c:35–64  ·  view source on GitHub ↗

Note each function call within given expression Example: given the expression: "abs(max(min(a), abs(k)))" referred_funcs will include: "abs", "max" and "min".

Source from the content-addressed store, hash-verified

33// Example: given the expression: "abs(max(min(a), abs(k)))"
34// referred_funcs will include: "abs", "max" and "min".
35static void _consume_function_call_expression
36(
37 const cypher_astnode_t *node,
38 rax *referred_funcs
39) {
40 cypher_astnode_type_t type = cypher_astnode_type(node);
41
42 if(type == CYPHER_AST_APPLY_OPERATOR ||
43 type == CYPHER_AST_APPLY_ALL_OPERATOR) {
44 // Expression is an Apply or Apply All operator.
45 bool apply_all = (type == CYPHER_AST_APPLY_ALL_OPERATOR);
46
47 // Retrieve the function name and add to rax.
48 const cypher_astnode_t *func = (!apply_all) ?
49 cypher_ast_apply_operator_get_func_name(node) :
50 cypher_ast_apply_all_operator_get_func_name(node);
51
52 const char *func_name = cypher_ast_function_name_get_value(func);
53 raxInsert(referred_funcs, (unsigned char *)func_name, strlen(func_name),
54 NULL, NULL);
55
56 if(apply_all) return; // Apply All operators have no arguments.
57 }
58
59 uint child_count = cypher_astnode_nchildren(node);
60 for(int i = 0; i < child_count; i++) {
61 const cypher_astnode_t *child = cypher_astnode_get_child(node, i);
62 _consume_function_call_expression(child, referred_funcs);
63 }
64}
65
66// this function returns the actual root of the query
67// as cypher_parse_result_t can have multiple roots such as comments

Callers 1

AST_ReferredFunctionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected