Skip to content

Commit

Permalink
chore: slice append replace loop (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored May 2, 2024
1 parent 02acf74 commit b0cdd35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 2 additions & 6 deletions planner/core/rule_predicate_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression)
func (p *LogicalUnionScan) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan) {
retainedPredicates, _ := p.children[0].PredicatePushDown(predicates)
p.conditions = make([]expression.Expression, 0, len(predicates))
for _, cond := range predicates {
p.conditions = append(p.conditions, cond)
}
p.conditions = append(p.conditions, predicates...)
// The conditions in UnionScan is only used for added rows, so parent Selection should not be removed.
return retainedPredicates, p
}
Expand Down Expand Up @@ -317,9 +315,7 @@ func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression
func (p *LogicalUnionAll) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan) {
for i, proj := range p.children {
newExprs := make([]expression.Expression, 0, len(predicates))
for _, cond := range predicates {
newExprs = append(newExprs, cond)
}
newExprs = append(newExprs, predicates...)
retCond, newChild := proj.PredicatePushDown(newExprs)
addSelection(p, newChild, retCond, i)
}
Expand Down
4 changes: 1 addition & 3 deletions store/mockstore/mocktikv/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,7 @@ func (e *topNExec) evalTopN(value [][]byte) error {
}

if e.heap.tryToAddRow(newRow) {
for _, val := range value {
newRow.data = append(newRow.data, val)
}
newRow.data = append(newRow.data, value...)
}
return errors.Trace(e.heap.err)
}
Expand Down

0 comments on commit b0cdd35

Please sign in to comment.