Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Nov 2, 2016
1 parent 553c6a5 commit ababaa9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Expand Up @@ -275,13 +275,22 @@ trait Nondeterministic extends Expression {
@transient
private[this] var initialized = false

/**
* Initializes internal states given the current partition index and mark this as initialized.
* Subclasses should override [[initializeInternal()]].
*/
final def initialize(partitionIndex: Int): Unit = {
initializeInternal(partitionIndex)
initialized = true
}

protected def initializeInternal(partitionIndex: Int): Unit

/**
* @inheritdoc
* Throws an exception if [[initialize()]] is not called yet.
* Subclasses should override [[evalInternal()]].
*/
final override def eval(input: InternalRow = null): Any = {
require(initialized,
s"Nondeterministic expression ${this.getClass.getName} should be initialized before eval.")
Expand Down
Expand Up @@ -27,8 +27,8 @@ abstract class Predicate {
def eval(r: InternalRow): Boolean

/**
* Initialize internal states given the current partition index.
* This is used by non-deterministic expressions to set initial states.
* Initializes internal states given the current partition index.
* This is used by nondeterministic expressions to set initial states.
* The default implementation does nothing.
*/
def initialize(partitionIndex: Int): Unit = {}
Expand Down
Expand Up @@ -67,8 +67,8 @@ package object expressions {
abstract class Projection extends (InternalRow => InternalRow) {

/**
* Initialize internal states given the current partition index.
* This is used by non-deterministic expressions to set initial states.
* Initializes internal states given the current partition index.
* This is used by nondeterministic expressions to set initial states.
* The default implementation does nothing.
*/
def initialize(partitionIndex: Int): Unit = {}
Expand Down

0 comments on commit ababaa9

Please sign in to comment.