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

Function _add_projections

src/ast/ast_rewrite_call_subquery.c:78–117  ·  view source on GitHub ↗

add projections to projections array, corresponding to the bound vars (names) and their internal representation (inter_names) if `direction` is 0 (false), projections from `names` to `inter_names` are added. if `directions` is 1, projections from `inter_names` to `names` are added. if `directions` is 2, projections from `inter_names` to `inter_names` are added. returns the new value of `proj_idx`

Source from the content-addressed store, hash-verified

76// added.
77// returns the new value of `proj_idx`
78static uint _add_projections
79(
80 cypher_astnode_t *projections[], // array of projections
81 uint proj_idx, // index to start adding projections
82 char **names, // bound vars
83 char **inter_names, // internal representation of bound vars
84 bool hide // hide or reveal vars
85) {
86 uint n_names = array_len(names);
87 uint n_inter_names = array_len(inter_names);
88 uint n_outer_names = n_inter_names - n_names;
89
90 if(hide) {
91 proj_idx = _add_names_projections(projections, proj_idx, names,
92 inter_names + n_outer_names, hide);
93 } else {
94 proj_idx = _add_names_projections(projections, proj_idx,
95 inter_names + n_outer_names, names, hide);
96 }
97
98 // -------------------------------------------------------------------------
99 // create projections for bound vars from outer context
100 // -------------------------------------------------------------------------
101 for(uint i = 0; i < n_outer_names; i++) {
102 // create a projection for the bound var
103 struct cypher_input_range range = {0};
104 cypher_astnode_t *exp = cypher_ast_identifier(inter_names[i],
105 strlen(inter_names[i]), range);
106 cypher_astnode_t *alias = cypher_ast_identifier(inter_names[i],
107 strlen(inter_names[i]), range);
108 cypher_astnode_t *children[2];
109 children[0] = exp;
110 children[1] = alias;
111
112 projections[proj_idx++] = cypher_ast_projection(exp, alias, children,
113 2, range);
114 }
115
116 return proj_idx;
117}
118
119// replaces a `WITH` clause, placed in clause_idx within `callsubquery`, with a
120// new `WITH` clause containing projections of `names` to `inter_names`

Callers 3

_replace_with_clauseFunction · 0.85
_add_first_clauseFunction · 0.85
_replace_return_clauseFunction · 0.85

Calls 2

array_lenFunction · 0.85
_add_names_projectionsFunction · 0.85

Tested by

no test coverage detected