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

Function _collect_aliases_in_path

src/ast/ast_shared.c:234–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static void _collect_aliases_in_path
235(
236 const cypher_astnode_t *path,
237 rax *identifiers
238) {
239 // collect path name if, if exists
240 if(cypher_astnode_type(path) == CYPHER_AST_NAMED_PATH) {
241 const cypher_astnode_t *ast_alias =
242 cypher_ast_named_path_get_identifier(path);
243 if(ast_alias != NULL) {
244 const char *identifier = cypher_ast_identifier_get_name(ast_alias);
245 raxTryInsert(identifiers, (unsigned char *)identifier,
246 strlen(identifier), (void *)ast_alias, NULL);
247 }
248 }
249
250 uint path_len = cypher_ast_pattern_path_nelements(path);
251 // every even offset corresponds to a node
252 for(uint i = 0; i < path_len; i += 2) {
253 const cypher_astnode_t *ast_node =
254 cypher_ast_pattern_path_get_element(path, i);
255 const cypher_astnode_t *ast_alias =
256 cypher_ast_node_pattern_get_identifier(ast_node);
257
258 if(ast_alias == NULL) continue; // unaliased node, do nothing
259
260 // add node alias to projection rax
261 const char *identifier = cypher_ast_identifier_get_name(ast_alias);
262 raxTryInsert(identifiers, (unsigned char *)identifier,
263 strlen(identifier), (void *)ast_alias, NULL);
264 }
265
266 // every odd offset corresponds to an edge
267 for(uint i = 1; i < path_len; i += 2) {
268 const cypher_astnode_t *ast_edge =
269 cypher_ast_pattern_path_get_element(path, i);
270 const cypher_astnode_t *ast_alias =
271 cypher_ast_rel_pattern_get_identifier(ast_edge);
272
273 if(ast_alias == NULL) continue; // unaliased edge, do nothing
274
275 // add edge alias to projection rax
276 const char *identifier = cypher_ast_identifier_get_name(ast_alias);
277 raxTryInsert(identifiers, (unsigned char *)identifier,
278 strlen(identifier), (void *)ast_alias, NULL);
279 }
280}
281
282static void _collect_aliases_in_pattern
283(

Callers 2

collect_aliases_in_scopeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected