def isFastExecution[A]()

in scalding-base/src/main/scala/com/twitter/scalding/ExecutionOptimizationRules.scala [78:112]


  def isFastExecution[A](e: Execution[A]): Boolean =
    areFastExecution(e :: Nil)

  /**
   * If `Execution` is `FlowDefExecution` or `WriteExecution`, we are considering those executions as slow,
   * since they will schedule some expensive work, like Hadoop or Spark Job.
   *
   * If `Execution` is `FlatMapped` or `UniqueIdExecution`, we are considering those executions as slow, since
   * we don't know which execution they can produce.
   *
   * Everything else we are considering as fast execution compare to `FlowDefExecution` and `WriteExecution`.
   */
  @tailrec
  def areFastExecution(es: List[Execution[Any]]): Boolean =
    es match {
      case Nil => true
      case h :: tail =>
        h match {
          case Execution.UniqueIdExecution(_)    => false
          case Execution.WriteExecution(_, _, _) => false
          case Execution.FlatMapped(_, _)        => false
          case Execution.BackendExecution(_)     => false

          case Execution.ReaderExecution         => areFastExecution(tail)
          case Execution.FutureConst(_)          => areFastExecution(tail)
          case Execution.GetCounters(e)          => areFastExecution(e :: tail)
          case Execution.ResetCounters(e)        => areFastExecution(e :: tail)
          case Execution.WithNewCache(e)         => areFastExecution(e :: tail)
          case Execution.TransformedConfig(e, _) => areFastExecution(e :: tail)
          case Execution.OnComplete(e, _)        => areFastExecution(e :: tail)
          case Execution.RecoverWith(e, _)       => areFastExecution(e :: tail)
          case Execution.Mapped(e, _)            => areFastExecution(e :: tail)
          case Execution.Zipped(one, two)        => areFastExecution(one :: two :: tail)
        }
    }