extracts node from 'qg' and places a copy of into 'graph'
| 133 | |
| 134 | // extracts node from 'qg' and places a copy of into 'graph' |
| 135 | static void _QueryGraph_ExtractNode |
| 136 | ( |
| 137 | const QueryGraph *qg, |
| 138 | QueryGraph *graph, |
| 139 | const cypher_astnode_t *ast_node |
| 140 | ) { |
| 141 | |
| 142 | // validate inputs |
| 143 | ASSERT(qg != NULL); |
| 144 | ASSERT(graph != NULL); |
| 145 | ASSERT(ast_node != NULL); |
| 146 | |
| 147 | // see if node is already in 'graph' |
| 148 | const char *alias = AST_ToString(ast_node); |
| 149 | QGNode *n = QueryGraph_GetNodeByAlias(graph, alias); |
| 150 | |
| 151 | if(n == NULL) { |
| 152 | // node is missing from 'graph', try getting it from 'qg' |
| 153 | n = QueryGraph_GetNodeByAlias(qg, alias); |
| 154 | if(n == NULL) { |
| 155 | // node is missing from 'qg', create it |
| 156 | // it is possible to get into a situation where we try to extract |
| 157 | // a path which contains entities that are missing from the |
| 158 | // "holistic" query graph consider: |
| 159 | // MATCH (a) WITH a WHERE (a)-[]->(:L1) in this case due to |
| 160 | // clause scoping only node 'a' is in 'qg' the filtered pattern |
| 161 | // which is being extracted from 'qg' has additional entities: |
| 162 | // an anonymous edge and node |
| 163 | _QueryGraphAddNode(graph, ast_node); |
| 164 | } else { |
| 165 | // add a clone of the original node |
| 166 | n = QGNode_Clone(n); |
| 167 | |
| 168 | // clear node label information |
| 169 | array_clear(n->labels); |
| 170 | array_clear(n->labelsID); |
| 171 | |
| 172 | QueryGraph_AddNode(graph, n); |
| 173 | // set node label information |
| 174 | _QueryGraphSetNodeLabel(n, ast_node); |
| 175 | } |
| 176 | } else { |
| 177 | // set node label information |
| 178 | _QueryGraphSetNodeLabel(n, ast_node); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // extracts edge from 'qg' and places a copy of into 'graph' |
| 183 | static void _QueryGraph_ExtractEdge |
no test coverage detected