| 232 | } |
| 233 | |
| 234 | void AST_PreparePathCreation |
| 235 | ( |
| 236 | const cypher_astnode_t *path, |
| 237 | const QueryGraph *qg, |
| 238 | rax *bound_vars, |
| 239 | NodeCreateCtx **nodes, |
| 240 | EdgeCreateCtx **edges |
| 241 | ) { |
| 242 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 243 | |
| 244 | QueryGraph *g = QueryGraph_ExtractPaths(qg, &path, 1); |
| 245 | uint path_elem_count = cypher_ast_pattern_path_nelements(path); |
| 246 | for(uint i = 0; i < path_elem_count; i ++) { |
| 247 | /* See if current entity needs to be created: |
| 248 | * 1. Current entity is NOT bound in a previous clause. |
| 249 | * 2. We have yet to account for this entity. */ |
| 250 | const cypher_astnode_t *elem = cypher_ast_pattern_path_get_element(path, i); |
| 251 | const char *alias = AST_ToString(elem); |
| 252 | |
| 253 | // Skip entities defined in previous clauses or already represented in our nodes/edges arrays. |
| 254 | int rc = raxTryInsert(bound_vars, (unsigned char *)alias, strlen(alias), NULL, NULL); |
| 255 | if(rc == 0) continue; |
| 256 | |
| 257 | if((i % 2) == 1) { |
| 258 | // relation |
| 259 | QGEdge *e = QueryGraph_GetEdgeByAlias(g, alias); |
| 260 | EdgeCreateCtx new_edge = _NewEdgeCreateCtx(gc, e, elem); |
| 261 | array_append(*edges, new_edge); |
| 262 | } else { |
| 263 | // node |
| 264 | QGNode *n = QueryGraph_GetNodeByAlias(g, alias); |
| 265 | NodeCreateCtx new_node = _NewNodeCreateCtx(gc, n, elem); |
| 266 | array_append(*nodes, new_node); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | QueryGraph_Free(g); |
| 271 | } |
| 272 | |
| 273 | //------------------------------------------------------------------------------ |
| 274 | // SORT operation |
no test coverage detected