org.apache.hadoop.hive.ql.exec
Class Task<T extends Serializable>

java.lang.Object
  extended by org.apache.hadoop.hive.ql.exec.Task<T>
All Implemented Interfaces:
Serializable, Node
Direct Known Subclasses:
ConditionalTask, CopyTask, DDLTask, ExecDriver, ExplainTask, FetchTask, FunctionTask, MapRedTask, MoveTask

public abstract class Task<T extends Serializable>
extends Object
implements Serializable, Node

Task implementation.

See Also:
Serialized Form

Field Summary
protected  List<Task<? extends Serializable>> childTasks
           
protected  HiveConf conf
           
protected  SessionState.LogHelper console
           
protected  Hive db
           
protected  DriverContext driverContext
           
protected  String id
           
protected  boolean initialized
           
protected  boolean isdone
           
protected  org.apache.commons.logging.Log LOG
           
protected  List<Task<? extends Serializable>> parentTasks
           
protected  QueryPlan queryPlan
           
protected  boolean queued
           
protected  boolean started
           
protected  HashMap<String,Long> taskCounters
           
protected  TaskHandle taskHandle
           
protected  T work
           
 
Constructor Summary
Task()
           
 
Method Summary
 boolean addDependentTask(Task<? extends Serializable> dependent)
          Add a dependent task on the current task.
 boolean done()
           
protected abstract  int execute(DriverContext driverContext)
          This method is overridden in each Task.
 int executeTask()
          This method is called in the Driver on every task.
 boolean fetch(ArrayList<String> res)
           
 List<? extends Node> getChildren()
          Gets the vector of children nodes.
 List<Task<? extends Serializable>> getChildTasks()
           
 HashMap<String,Long> getCounters()
           
 List<Task<? extends Serializable>> getDependentTasks()
          The default dependent tasks are just child tasks, but different types could implement their own (e.g.
 String getId()
           
 boolean getInitialized()
           
 List<Task<? extends Serializable>> getParentTasks()
           
 boolean getQueued()
           
 int getType()
          Should be overridden to return the type of the specific task among the types in TaskType.
 T getWork()
           
 boolean hasReduce()
           
 void initialize(HiveConf conf, QueryPlan queryPlan, DriverContext driverContext)
           
 boolean isMapRedTask()
           
 boolean isRunnable()
           
 void progress(TaskHandle taskHandle)
          Update the progress of the task within taskHandle and also dump the progress information to the history file.
 void removeDependentTask(Task<? extends Serializable> dependent)
          Remove the dependent task.
 void setChildTasks(List<Task<? extends Serializable>> childTasks)
           
 void setDone()
           
 void setId(String id)
           
 void setInitialized()
           
 void setParentTasks(List<Task<? extends Serializable>> parentTasks)
           
 void setQueued()
           
 void setStarted()
           
 void setWork(T work)
           
 boolean started()
           
 void updateCounters(TaskHandle th)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hive.ql.lib.Node
getName
 

Field Detail

started

protected transient boolean started

initialized

protected transient boolean initialized

isdone

protected transient boolean isdone

queued

protected transient boolean queued

conf

protected transient HiveConf conf

db

protected transient Hive db

LOG

protected transient org.apache.commons.logging.Log LOG

console

protected transient SessionState.LogHelper console

queryPlan

protected transient QueryPlan queryPlan

taskHandle

protected transient TaskHandle taskHandle

taskCounters

protected transient HashMap<String,Long> taskCounters

driverContext

protected transient DriverContext driverContext

childTasks

protected List<Task<? extends Serializable>> childTasks

parentTasks

protected List<Task<? extends Serializable>> parentTasks

id

protected String id

work

protected T extends Serializable work
Constructor Detail

Task

public Task()
Method Detail

initialize

public void initialize(HiveConf conf,
                       QueryPlan queryPlan,
                       DriverContext driverContext)

executeTask

public int executeTask()
This method is called in the Driver on every task. It updates counters and calls execute(), which is overridden in each task

Returns:
return value of execute()

execute

protected abstract int execute(DriverContext driverContext)
This method is overridden in each Task. TODO execute should return a TaskHandle.

Returns:
status of executing the task

progress

public void progress(TaskHandle taskHandle)
              throws IOException
Update the progress of the task within taskHandle and also dump the progress information to the history file.

Parameters:
taskHandle - task handle returned by execute
Throws:
IOException

fetch

public boolean fetch(ArrayList<String> res)
              throws IOException
Throws:
IOException

setChildTasks

public void setChildTasks(List<Task<? extends Serializable>> childTasks)

getChildren

public List<? extends Node> getChildren()
Description copied from interface: Node
Gets the vector of children nodes. This is used in the graph walker algorithms.

Specified by:
getChildren in interface Node
Returns:
List

getChildTasks

public List<Task<? extends Serializable>> getChildTasks()

setParentTasks

public void setParentTasks(List<Task<? extends Serializable>> parentTasks)

getParentTasks

public List<Task<? extends Serializable>> getParentTasks()

getDependentTasks

public List<Task<? extends Serializable>> getDependentTasks()
The default dependent tasks are just child tasks, but different types could implement their own (e.g. ConditionalTask will use the listTasks as dependents).

Returns:
a list of tasks that are dependent on this task.

addDependentTask

public boolean addDependentTask(Task<? extends Serializable> dependent)
Add a dependent task on the current task. Return if the dependency already existed or is this a new one

Returns:
true if the task got added false if it already existed

removeDependentTask

public void removeDependentTask(Task<? extends Serializable> dependent)
Remove the dependent task.

Parameters:
dependent - the task to remove

setStarted

public void setStarted()

started

public boolean started()

done

public boolean done()

setDone

public void setDone()

setQueued

public void setQueued()

getQueued

public boolean getQueued()

setInitialized

public void setInitialized()

getInitialized

public boolean getInitialized()

isRunnable

public boolean isRunnable()

setWork

public void setWork(T work)

getWork

public T getWork()

setId

public void setId(String id)

getId

public String getId()

isMapRedTask

public boolean isMapRedTask()

hasReduce

public boolean hasReduce()

updateCounters

public void updateCounters(TaskHandle th)
                    throws IOException
Throws:
IOException

getCounters

public HashMap<String,Long> getCounters()

getType

public int getType()
Should be overridden to return the type of the specific task among the types in TaskType.

Returns:
TaskTypeType.* or -1 if not overridden


Copyright © 2010 The Apache Software Foundation