propagateSortKey analyzes a Seq and attempts to push the scan order of the data source into the first downstream aggregation. (We could continue the analysis past that point but don't bother yet because we do not yet support any optimization past the first aggregation.) For parallel paths, we prop
(seq dag.Seq, parents []order.SortKeys)
| 300 | // past the first aggregation.) For parallel paths, we propagate |
| 301 | // the scan order if its the same at egress of all of the paths. |
| 302 | func (o *Optimizer) propagateSortKey(seq dag.Seq, parents []order.SortKeys) ([]order.SortKeys, error) { |
| 303 | if len(seq) == 0 { |
| 304 | return parents, nil |
| 305 | } |
| 306 | for _, op := range seq { |
| 307 | var err error |
| 308 | parents, err = o.propagateSortKeyOp(op, parents) |
| 309 | if err != nil { |
| 310 | return []order.SortKeys{nil}, err |
| 311 | } |
| 312 | } |
| 313 | return parents, nil |
| 314 | } |
| 315 | |
| 316 | func (o *Optimizer) propagateSortKeyOp(op dag.Op, parents []order.SortKeys) ([]order.SortKeys, error) { |
| 317 | switch op.(type) { |
no test coverage detected