telepath / com.github.giedomak.telepath.datamodels.plans.utilities / MultiTreeFlattener

MultiTreeFlattener

object MultiTreeFlattener (source)

Flatten ParseTrees into multi-trees.

We escalate the children from a node to its parent if both the node and its parent have the same operator.

Example input:

        CONCATENATION
      /       |        \
     a  CONCATENATION   f
          /      \
      UNION       e
     /    \
    b    UNION
         /  \
        c    d

Output:

     CONCATENATION
     /   |    |  \
    a  UNION  e   f
       / | \
      b  c  d

Functions

flatten

fun <ImplementingTree : AbstractMultiTree<ImplementingTree>> flatten(tree: ImplementingTree): ImplementingTree

Flatten a given LogicalPlan recursively into a multi-tree.