Trait/Object

com.twitter.scalding

Execution

Related Docs: object Execution | package scalding

Permalink

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
Source
Execution.scala
Linear Supertypes
Serializable, AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Execution
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
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])]]

    Permalink

    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: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

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

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

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

    Permalink

    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

  9. def finalize(): Unit

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

    Permalink

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

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

    Permalink

    This is the same as flatMap(identity)

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

    Permalink

    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.

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

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

    Permalink

    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.

  15. val hashCode: Int

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

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

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

    Permalink

    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.

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

    Permalink

    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.

  24. def resetCounters: Execution[T]

    Permalink

    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

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

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

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

    Permalink

    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(_ => ())

  29. final def wait(): Unit

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

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

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

    Permalink

    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.

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

    Permalink

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

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

    Users should never directly call this method, call .filter

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

    Permalink

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped