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

Function reduceDistinct

src/execution_plan/optimizations/reduce_distinct.c:18–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 * from the execution plan. */
17
18void reduceDistinct(ExecutionPlan *plan) {
19 // Look for Distinct operations.
20 OpBase **distinct_ops = ExecutionPlan_CollectOps(plan->root, OPType_DISTINCT);
21
22 for(uint i = 0; i < array_len(distinct_ops); i++) {
23 OpBase *distinct = distinct_ops[i];
24 ASSERT(distinct->childCount == 1);
25 if(distinct->children[0]->type == OPType_AGGREGATE) {
26 // We can remove the Distinct op if its child is an aggregate operation,
27 // as its results will inherently be unique.
28 ExecutionPlan_RemoveOp(plan, distinct);
29 OpBase_Free(distinct);
30 }
31 }
32
33 array_free(distinct_ops);
34}
35

Callers 1

optimizePlanFunction · 0.85

Calls 5

ExecutionPlan_CollectOpsFunction · 0.85
array_lenFunction · 0.85
ExecutionPlan_RemoveOpFunction · 0.85
OpBase_FreeFunction · 0.85
array_freeFunction · 0.85

Tested by

no test coverage detected