telepath / com.github.giedomak.telepath.datamodels.plans.utilities / LogicalPlanSubtree / subtreesOfSize

subtreesOfSize

fun subtreesOfSize(tree: LogicalPlan, targetSize: Int): List<LogicalPlan> (source)

Find all (partial) subtrees of a given targetSize.

We use a sliding window to try and find a subList of a nodes' children which does match the given targetSize.

Example tree:

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

subtreesOfSize(tree, 2):

    UNION   UNION    CONCATENATION    CONCATENATION
     / \     / \         /   \            /   \
    b   c   c   d       e     f          f     g

Parameters

targetSize - We are looking for all (partial) subtrees of this size.