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

Function _CloneOpTree

src/execution_plan/execution_plan_clone.c:27–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27static OpBase *_CloneOpTree(OpBase *template_current, dict* old_to_new) {
28 ExecutionPlan *plan_segment;
29
30 dictEntry *entry = HashTableFind(old_to_new, template_current->plan);
31 if(entry == NULL) {
32 plan_segment = _ClonePlanInternals(template_current->plan);
33 HashTableAdd(old_to_new, (void *)template_current->plan, (void *)plan_segment);
34 } else {
35 plan_segment = (ExecutionPlan *)HashTableGetVal(entry);
36 }
37
38 // Temporarily set the thread-local AST to be the one referenced by this ExecutionPlan segment.
39 QueryCtx_SetAST(plan_segment->ast_segment);
40
41 // Clone the current operation.
42 OpBase *clone_current = OpBase_Clone(plan_segment, template_current);
43 if(plan_segment->root == NULL) plan_segment->root = clone_current;
44
45 for(uint i = 0; i < template_current->childCount; i++) {
46 // Recursively visit and clone the op's children.
47 OpBase *child_op = _CloneOpTree(template_current->children[i],
48 old_to_new);
49 ExecutionPlan_AddOp(clone_current, child_op);
50 }
51
52 return clone_current;
53}
54
55static ExecutionPlan *_ExecutionPlan_Clone(const ExecutionPlan *template) {
56 // create mapping from old exec-plans to the ones

Callers 1

_ExecutionPlan_CloneFunction · 0.85

Calls 7

HashTableFindFunction · 0.85
_ClonePlanInternalsFunction · 0.85
HashTableAddFunction · 0.85
HashTableGetValFunction · 0.85
QueryCtx_SetASTFunction · 0.85
OpBase_CloneFunction · 0.85
ExecutionPlan_AddOpFunction · 0.85

Tested by

no test coverage detected