org.apache.hadoop.hive.ql
Class Driver

java.lang.Object
  extended by org.apache.hadoop.hive.ql.Driver
All Implemented Interfaces:
CommandProcessor

public class Driver
extends Object
implements CommandProcessor


Field Summary
protected  int tryCount
           
 
Constructor Summary
Driver()
           
Driver(HiveConf conf)
          for backwards compatibility with current tests
 
Method Summary
 int acquireReadWriteLocks()
          Acquire read and write locks needed by the statement.
 int close()
           
 int compile(String command)
          Compile a new query.
 int compile(String command, boolean resetTaskIds)
          Compile a new query, but potentially reset taskID counter.
 void destroy()
           
 int execute()
           
 org.apache.hadoop.mapred.ClusterStatus getClusterStatus()
          Return the status information about the Map-Reduce cluster
 int getMaxRows()
          Return the maximum number of rows returned by getResults
 QueryPlan getPlan()
           
 Query getQueryPlan()
           
 boolean getResults(ArrayList<String> res)
           
 Schema getSchema()
           
static Schema getSchema(BaseSemanticAnalyzer sem, HiveConf conf)
          Get a Schema with fields represented with native Hive types
 Schema getThriftSchema()
          Get a Schema with fields represented with Thrift DDL types
 int getTryCount()
           
 boolean hasReduceTasks(List<Task<? extends Serializable>> tasks)
           
 void init()
           
 void launchTask(Task<? extends Serializable> tsk, String queryId, boolean noName, Map<TaskResult,TaskRunner> running, String jobname, int jobs, DriverContext cxt)
          Launches a new task
 TaskResult pollTasks(Set<TaskResult> results)
          Polls running tasks to see if a task has ended.
 void restoreSession(org.apache.hadoop.hive.ql.Driver.QueryState qs)
           
 CommandProcessorResponse run(String command)
           
 void saveSession(org.apache.hadoop.hive.ql.Driver.QueryState qs)
           
 void setMaxRows(int maxRows)
          Set the maximum number of rows returned by getResults
 void setTryCount(int tryCount)
           
 void taskCleanup()
          Cleans up remaining tasks in case of failure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tryCount

protected int tryCount
Constructor Detail

Driver

public Driver(HiveConf conf)
for backwards compatibility with current tests


Driver

public Driver()
Method Detail

init

public void init()
Specified by:
init in interface CommandProcessor

getClusterStatus

public org.apache.hadoop.mapred.ClusterStatus getClusterStatus()
                                                        throws Exception
Return the status information about the Map-Reduce cluster

Throws:
Exception

getSchema

public Schema getSchema()

getSchema

public static Schema getSchema(BaseSemanticAnalyzer sem,
                               HiveConf conf)
Get a Schema with fields represented with native Hive types


getThriftSchema

public Schema getThriftSchema()
                       throws Exception
Get a Schema with fields represented with Thrift DDL types

Throws:
Exception

getMaxRows

public int getMaxRows()
Return the maximum number of rows returned by getResults


setMaxRows

public void setMaxRows(int maxRows)
Set the maximum number of rows returned by getResults


hasReduceTasks

public boolean hasReduceTasks(List<Task<? extends Serializable>> tasks)

compile

public int compile(String command)
Compile a new query. Any currently-planned query associated with this Driver is discarded.

Parameters:
command - The SQL query to compile.

saveSession

public void saveSession(org.apache.hadoop.hive.ql.Driver.QueryState qs)

restoreSession

public void restoreSession(org.apache.hadoop.hive.ql.Driver.QueryState qs)

compile

public int compile(String command,
                   boolean resetTaskIds)
Compile a new query, but potentially reset taskID counter. Not resetting task counter is useful for generating re-entrant QL queries.

Parameters:
command - The HiveQL query to compile
resetTaskIds - Resets taskID counter if true.
Returns:
0 for ok

getPlan

public QueryPlan getPlan()
Returns:
The current query plan associated with this Driver, if any.

acquireReadWriteLocks

public int acquireReadWriteLocks()
Acquire read and write locks needed by the statement. The list of objects to be locked are obtained from he inputs and outputs populated by the compiler. The lock acuisition scheme is pretty simple. If all the locks cannot be obtained, error out. Deadlock is avoided by making sure that the locks are lexicographically sorted.


run

public CommandProcessorResponse run(String command)
                             throws CommandNeedRetryException
Specified by:
run in interface CommandProcessor
Throws:
CommandNeedRetryException

execute

public int execute()
            throws CommandNeedRetryException
Throws:
CommandNeedRetryException

launchTask

public void launchTask(Task<? extends Serializable> tsk,
                       String queryId,
                       boolean noName,
                       Map<TaskResult,TaskRunner> running,
                       String jobname,
                       int jobs,
                       DriverContext cxt)
Launches a new task

Parameters:
tsk - task being launched
queryId - Id of the query containing the task
noName - whether the task has a name set
running - map from taskresults to taskrunners
jobname - name of the task, if it is a map-reduce job
jobs - number of map-reduce jobs
cxt - the driver context

taskCleanup

public void taskCleanup()
Cleans up remaining tasks in case of failure


pollTasks

public TaskResult pollTasks(Set<TaskResult> results)
Polls running tasks to see if a task has ended.

Parameters:
results - Set of result objects for running tasks
Returns:
The result object for any completed/failed task

getResults

public boolean getResults(ArrayList<String> res)
                   throws IOException,
                          CommandNeedRetryException
Throws:
IOException
CommandNeedRetryException

getTryCount

public int getTryCount()

setTryCount

public void setTryCount(int tryCount)

close

public int close()

destroy

public void destroy()

getQueryPlan

public Query getQueryPlan()
                   throws IOException
Throws:
IOException


Copyright © 2013 The Apache Software Foundation