org.apache.hadoop.hive.ql
Class Context

java.lang.Object
  extended by org.apache.hadoop.hive.ql.Context

public class Context
extends Object

Context for Semantic Analyzers. Usage: not reusable - construct a new one for each query should call clear() at end of use to remove temporary folders


Field Summary
protected  boolean explain
           
protected  int pathid
           
 
Constructor Summary
Context(HiveConf conf)
           
Context(HiveConf conf, String executionId)
          Create a Context with a given executionId.
 
Method Summary
 void clear()
           
static String generateExecutionId()
          Generate a unique executionId.
 boolean getExplain()
          Find out whether the current query is an explain query.
 String getExternalTmpFileURI(URI extURI)
          Get a path to store tmp data destined for external URI.
 String getLocalScratchDir()
          Create a local scratch directory on demand and return it.
 String getLocalTmpFileURI()
          Get a tmp path on local host to store intermediate data.
 String getMRScratchDir()
          Create a map-reduce scratch directory on demand and return it.
 String getMRTmpFileURI()
          Get a path to store map-reduce intermediate data in.
 org.apache.hadoop.fs.Path getQueryPath()
           
 org.apache.hadoop.fs.Path getResDir()
           
 org.apache.hadoop.fs.Path getResFile()
           
 DataInput getStream()
           
 org.antlr.runtime.TokenRewriteStream getTokenRewriteStream()
           
 boolean isLocalOnlyExecutionMode()
          Does Hive wants to run tasks entirely on the local machine (where the query is being compiled)? Today this translates into running hadoop jobs locally
 boolean isMRTmpFileURI(String uriStr)
          Check if path is tmp path.
 void setExplain(boolean value)
          Set the context on whether the current query is an explain query.
 void setResDir(org.apache.hadoop.fs.Path resDir)
           
 void setResFile(org.apache.hadoop.fs.Path resFile)
           
 void setTokenRewriteStream(org.antlr.runtime.TokenRewriteStream tokenRewriteStream)
          Set the token rewrite stream being used to parse the current top-level SQL statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pathid

protected int pathid

explain

protected boolean explain
Constructor Detail

Context

public Context(HiveConf conf)
        throws IOException
Throws:
IOException

Context

public Context(HiveConf conf,
               String executionId)
        throws IOException
Create a Context with a given executionId. ExecutionId, together with user name and conf, will determine the temporary directory locations.

Throws:
IOException
Method Detail

setExplain

public void setExplain(boolean value)
Set the context on whether the current query is an explain query.

Parameters:
value - true if the query is an explain query, false if not

getExplain

public boolean getExplain()
Find out whether the current query is an explain query.

Returns:
true if the query is an explain query, false if not

getMRScratchDir

public String getMRScratchDir()
Create a map-reduce scratch directory on demand and return it.


getLocalScratchDir

public String getLocalScratchDir()
Create a local scratch directory on demand and return it.


isMRTmpFileURI

public boolean isMRTmpFileURI(String uriStr)
Check if path is tmp path. the assumption is that all uri's relative to scratchdir are temporary.

Returns:
true if a uri is a temporary uri for map-reduce intermediate data, false otherwise

getMRTmpFileURI

public String getMRTmpFileURI()
Get a path to store map-reduce intermediate data in.

Returns:
next available path for map-red intermediate data

getLocalTmpFileURI

public String getLocalTmpFileURI()
Get a tmp path on local host to store intermediate data.

Returns:
next available tmp path on local fs

getExternalTmpFileURI

public String getExternalTmpFileURI(URI extURI)
Get a path to store tmp data destined for external URI.

Parameters:
extURI - external URI to which the tmp data has to be eventually moved
Returns:
next available tmp path on the file system corresponding extURI

getResFile

public org.apache.hadoop.fs.Path getResFile()
Returns:
the resFile

setResFile

public void setResFile(org.apache.hadoop.fs.Path resFile)
Parameters:
resFile - the resFile to set

getResDir

public org.apache.hadoop.fs.Path getResDir()
Returns:
the resDir

setResDir

public void setResDir(org.apache.hadoop.fs.Path resDir)
Parameters:
resDir - the resDir to set

clear

public void clear()
           throws IOException
Throws:
IOException

getStream

public DataInput getStream()

setTokenRewriteStream

public void setTokenRewriteStream(org.antlr.runtime.TokenRewriteStream tokenRewriteStream)
Set the token rewrite stream being used to parse the current top-level SQL statement. Note that this should not be used for other parsing activities; for example, when we encounter a reference to a view, we switch to a new stream for parsing the stored view definition from the catalog, but we don't clobber the top-level stream in the context.

Parameters:
tokenRewriteStream - the stream being used

getTokenRewriteStream

public org.antlr.runtime.TokenRewriteStream getTokenRewriteStream()
Returns:
the token rewrite stream being used to parse the current top-level SQL statement, or null if it isn't available (e.g. for parser tests)

generateExecutionId

public static String generateExecutionId()
Generate a unique executionId. An executionId, together with user name and the configuration, will determine the temporary locations of all intermediate files. In the future, users can use the executionId to resume a query.


getQueryPath

public org.apache.hadoop.fs.Path getQueryPath()

isLocalOnlyExecutionMode

public boolean isLocalOnlyExecutionMode()
Does Hive wants to run tasks entirely on the local machine (where the query is being compiled)? Today this translates into running hadoop jobs locally



Copyright © 2010 The Apache Software Foundation