From f910c8644130fb3b3aa131a1031aedf24d3b95f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Lovitz Date: Wed, 18 Mar 2020 17:59:50 -0400 Subject: [PATCH] Simplify op-freeing logic in utilizeIndices --- src/execution_plan/optimizations/utilize_indices.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/execution_plan/optimizations/utilize_indices.c b/src/execution_plan/optimizations/utilize_indices.c index 4a589bf8a8..279acd2843 100644 --- a/src/execution_plan/optimizations/utilize_indices.c +++ b/src/execution_plan/optimizations/utilize_indices.c @@ -497,19 +497,15 @@ void reduce_scan_op(ExecutionPlan *plan, NodeByLabelScan *scan) { RSResultsIterator *iter = RediSearch_GetResultsIterator(root, rs_idx); // Build the Index Scan. OpBase *indexOp = NewIndexScanOp(scan->op.plan, scan->g, scan->n, rs_idx, iter); - /* Remove the redundant filter op without reordering its parent op's child array - * (avoiding problems with stream-sensitive ops like SemiApply). */ - OpBase *last_filter = (OpBase *)array_pop(filters); - filters_count--; - ExecutionPlan_RemoveOp(plan, last_filter); - OpBase_Free(last_filter); /* Replace the redundant scan op with the newly-constructed Index Scan. */ ExecutionPlan_ReplaceOp(plan, (OpBase *)scan, indexOp); OpBase_Free((OpBase *)scan); } - // Free all remaining filters. + /* Remove and free all now-redundant filter ops. + * Since this is a chain of single-child operations, all operations are replaced in-place, + * avoiding problems with stream-sensitive ops like SemiApply. */ for(uint i = 0; i < filters_count; i++) { OpFilter *filter = filters[i]; ExecutionPlan_RemoveOp(plan, (OpBase *)filter);