Skip to content

Commit

Permalink
Simplify op-freeing logic in utilizeIndices
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylovitz committed Mar 18, 2020
1 parent 379fa40 commit f910c86
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/execution_plan/optimizations/utilize_indices.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f910c86

Please sign in to comment.