com.twitter.scalding

Execution

sealed trait Execution[+T] extends Serializable

Execution[T] represents and computation that can be run and will produce a value T and keep track of counters incremented inside of TypedPipes using a Stat.

Execution[T] is the recommended way to compose multistep computations that involve branching (if/then), intermediate calls to remote services, file operations, or looping (e.g. testing for convergence).

Library functions are encouraged to implement functions from TypedPipes or ValuePipes to Execution[R] for some result R. Refrain from calling run in library code. Let the caller of your library call run.

Note this is a Monad, meaning flatMap composes in series as you expect. It is also an applicative functor, which means zip (called join in some libraries) composes two Executions is parallel. Prefer zip to flatMap if you want to run two Executions in parallel.

Self Type
Execution[T] with Product
Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Execution
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def runStats(conf: Config, mode: Mode, cache: EvalCache)(implicit cec: scala.concurrent.ExecutionContext): Trampoline[Future[(T, Map[Long, ExecutionCounters])]]

    This is the internal method that must be implemented Given a config, mode, and cache of evaluations for this config and mode, return the new cache with as much evaluation as possible before the future completes, and a future of the result, counters and cache after the future is complete

    This is the internal method that must be implemented Given a config, mode, and cache of evaluations for this config and mode, return the new cache with as much evaluation as possible before the future completes, and a future of the result, counters and cache after the future is complete

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(other: Any): Boolean

    Definition Classes
    Execution → AnyRef → Any
  10. def filter(pred: (T) ⇒ Boolean): Execution[T]

    Scala uses the filter method in for syntax for pattern matches that can fail.

    Scala uses the filter method in for syntax for pattern matches that can fail. If this filter is false, the result of run will be an exception in the future

  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flatMap[U](fn: (T) ⇒ Execution[U]): Execution[U]

    First run this Execution, then move to the result of the function

  13. def flatten[U](implicit ev: <:<[T, Execution[U]]): Execution[U]

    This is the same as flatMap(identity)

  14. def getAndResetCounters: Execution[(T, ExecutionCounters)]

    Reads the counters and resets them to zero.

    Reads the counters and resets them to zero. Probably what you want in a loop that is using counters to check for convergence.

  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. def getCounters: Execution[(T, ExecutionCounters)]

    Reads the counters into the value, but does not reset them.

    Reads the counters into the value, but does not reset them. You may want .getAndResetCounters.

  17. val hashCode: Int

    Definition Classes
    Execution → AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  19. def liftToTry: Execution[Try[T]]

    Lift an Execution into a Try

    Lift an Execution into a Try

    When this function is called the Execution should never be failed instead only the Try.

  20. def map[U](fn: (T) ⇒ U): Execution[U]

    Apply a pure function to the result.

    Apply a pure function to the result. This may not be called if subsequently the result is discarded with .unit For side effects see onComplete.

  21. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  24. def onComplete(fn: (Try[T]) ⇒ Unit): Execution[T]

    This function is called when the current run is completed.

    This function is called when the current run is completed. This is only a side effect (see unit return).

    ALSO You must .run the result. If you throw away the result of this call, your fn will never be called. When you run the result, the Future you get will not be complete unless fn has completed running. If fn throws, it will be handled be the scala.concurrent.ExecutionContext.reportFailure NOT by returning a Failure in the Future.

  25. def recoverWith[U >: T](rec: PartialFunction[Throwable, Execution[U]]): Execution[U]

    This allows you to handle a failure by giving a replacement execution in some cases.

    This allows you to handle a failure by giving a replacement execution in some cases. This execution may be a retry if you know that your execution can have spurious errors, or it could be a constant or an alternate way to compute. Be very careful creating looping retries that could hammer your cluster when the data is missing or when when there is some real problem with your job logic.

  26. def resetCounters: Execution[T]

    Resets the counters back to zero.

    Resets the counters back to zero. This is useful if you want to reset before a zip or a call to flatMap

  27. final def run(conf: Config, mode: Mode)(implicit cec: scala.concurrent.ExecutionContext): Future[T]

    This causes the Execution to occur.

    This causes the Execution to occur. The result is not cached, so each call to run will result in the computation being re-run. Avoid calling this until the last possible moment by using flatMap, zip and recoverWith.

    Seriously: pro-style is for this to be called only once in a program.

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  29. def toString(): String

    Definition Classes
    AnyRef → Any
  30. def unit: Execution[Unit]

    This is convenience for when we don't care about the result.

    This is convenience for when we don't care about the result. like .map(_ => ())

  31. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def waitFor(conf: Config, mode: Mode): Try[T]

    This waits synchronously on run, using the global execution context Avoid calling this if possible, prefering run or just Execution composition.

    This waits synchronously on run, using the global execution context Avoid calling this if possible, prefering run or just Execution composition. Every time someone calls this, be very suspect. It is always code smell. Very seldom should you need to wait on a future.

  35. def withFilter(p: (T) ⇒ Boolean): Execution[T]

    This is here to silence warnings in for comprehensions, but is identical to .

    This is here to silence warnings in for comprehensions, but is identical to .filter.

    Users should never directly call this method, call .filter

  36. def zip[U](that: Execution[U]): Execution[(T, U)]

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped