Skip to content

Commit

Permalink
Added more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerk committed May 28, 2016
1 parent 216964d commit 973f270
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/workflow/graph/Cacher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import scala.reflect.ClassTag
* @tparam T Type of the input to cache.
*/
case class Cacher[T: ClassTag](name: Option[String] = None) extends Transformer[T,T] with Logging {
override protected def apply(in: RDD[T]): RDD[T] = {
override def apply(in: RDD[T]): RDD[T] = {
logInfo(s"CACHING ${name.getOrElse(in.id)}")
name match {
case Some(x) => in.cache().setName(x)
case None => in.cache()
}
}

override protected def apply(in: T): T = in
override def apply(in: T): T = in
}
3 changes: 2 additions & 1 deletion src/main/scala/workflow/graph/ExtractSaveablePrefixes.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package workflow.graph

/**
* Extract the prefixes whose state we want to save (aka for any cacher or estimator node)
* Extract the prefixes of all Nodes whose state we want to save for reuse by other Pipeline apply and fit calls.
* This is all nodes that either have a Cacher or an EstimatorOperator as the internal operator.
*/
object ExtractSaveablePrefixes extends Rule {
override def apply(plan: Graph, prefixes: Map[NodeId, Prefix]): (Graph, Map[NodeId, Prefix]) = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/workflow/graph/GraphExecutor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private[graph] class GraphExecutor(val graph: Graph, val optimize: Boolean = tru
val operator = optimizedGraph.getOperator(node)
val expression = operator.execute(depExpressions)

// Save state if prefix exists!
// Save state if the prefix is being considered for saving/loading state!
// Note: This whole process isn't threadsafe & things could get messed up if
// multiple pipelines are executing and/or optimizing at once
if (prefixes.contains(node)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/workflow/graph/Identity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import scala.reflect.ClassTag
* @tparam T Type of the input and, by definition, output.
*/
case class Identity[T : ClassTag]() extends Transformer[T,T] {
override protected def apply(in: T): T = in
override protected def apply(in: RDD[T]): RDD[T] = in
override def apply(in: T): T = in
override def apply(in: RDD[T]): RDD[T] = in
}
5 changes: 5 additions & 0 deletions src/main/scala/workflow/graph/Prefix.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ private[graph] object Prefix {
}
}

/**
* This case class represents the logical prefix of a node in a Pipeline.
* @param operator The operator stored at the node
* @param deps The prefixes of the operator's dependencies
*/
private[graph] case class Prefix(operator: Operator, deps: Seq[Prefix])
3 changes: 2 additions & 1 deletion src/main/scala/workflow/graph/SavedStateLoadRule.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package workflow.graph

/**
* A rule to load any saved state for the nodes w/ prefixes attached
* A rule to load any saved state for the global [[Pipeline.state]] prefix state table
* for nodes we want to consider either loading or saving the results of.
*/
object SavedStateLoadRule extends Rule {
override def apply(plan: Graph, prefixes: Map[NodeId, Prefix]): (Graph, Map[NodeId, Prefix]) = {
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/workflow/graph/UnusedBranchRemovalRule.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package workflow.graph

/**
* A rule to remove all nodes & sources in a graph that don't lead to any sink.
* A rule to remove all nodes & sources in a graph that don't lead to any sink,
* and are effectively unused.
*/
object UnusedBranchRemovalRule extends Rule {
override def apply(plan: Graph, prefixes: Map[NodeId, Prefix]): (Graph, Map[NodeId, Prefix]) = {
Expand Down

0 comments on commit 973f270

Please sign in to comment.