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
Direct Known Subclasses:
ConditionalTask, CopyTask, DDLTask, ExecDriver, ExplainTask, FetchTask, FunctionTask, MapRedTask, MoveTask

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

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  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  Map<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()
          This method is overridden in each Task.
 int executeTask()
          This method is called in the Driver on every task.
 boolean fetch(Vector<String> res)
           
 List<Task<? extends Serializable>> getChildTasks()
           
 Map<String,Long> getCounters()
           
 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)
           
 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
 

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 Map<String,Long> taskCounters

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)

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()
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(Vector<String> res)
              throws IOException
Throws:
IOException

setChildTasks

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

getChildTasks

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

setParentTasks

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

getParentTasks

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

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 Map<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 © 2009 The Apache Software Foundation