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

Function QueryGraph_ExtractPatterns

src/graph/query_graph.c:341–368  ·  view source on GitHub ↗

clones patterns from 'qg' into 'graph'

Source from the content-addressed store, hash-verified

339
340// clones patterns from 'qg' into 'graph'
341QueryGraph *QueryGraph_ExtractPatterns
342(
343 const QueryGraph *qg,
344 const cypher_astnode_t **patterns,
345 uint n
346) {
347
348 // validate inputs
349 ASSERT(qg != NULL && patterns != NULL);
350
351 // create an empty query graph
352 uint node_count = QueryGraph_NodeCount(qg);
353 uint edge_count = QueryGraph_EdgeCount(qg);
354 QueryGraph *graph = QueryGraph_New(node_count, edge_count);
355 ASSERT(graph != NULL);
356
357 // extract paths described by each pattern
358 for(uint i = 0; i < n; i++) {
359 const cypher_astnode_t *pattern = patterns[i];
360 uint npaths = cypher_ast_pattern_npaths(pattern);
361 for(uint j = 0; j < npaths; j ++) {
362 const cypher_astnode_t *path = cypher_ast_pattern_get_path(pattern, j);
363 _QueryGraph_ExtractPath(qg, graph, path);
364 }
365 }
366
367 return graph;
368}
369
370// build a query graph from AST
371QueryGraph *BuildQueryGraph

Callers 3

buildMatchOpTreeFunction · 0.85

Calls 4

QueryGraph_NodeCountFunction · 0.85
QueryGraph_EdgeCountFunction · 0.85
QueryGraph_NewFunction · 0.85
_QueryGraph_ExtractPathFunction · 0.85

Tested by 1