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


Constructor Summary
Context(org.apache.hadoop.conf.Configuration conf)
           
Context(org.apache.hadoop.conf.Configuration conf, String executionId)
          Create a Context with a given executionId.
 
Method Summary
 void addCS(String path, org.apache.hadoop.fs.ContentSummary cs)
           
 void clear()
           
static String generateExecutionId()
          Generate a unique executionId.
 String getCmd()
          Find the original query command.
 org.apache.hadoop.conf.Configuration getConf()
           
 org.apache.hadoop.fs.ContentSummary getCS(org.apache.hadoop.fs.Path path)
           
 org.apache.hadoop.fs.ContentSummary getCS(String path)
           
 boolean getExplain()
          Find whether the current query is an explain query
 boolean getExplainLogical()
          Find whether the current query is a logical explain query
 org.apache.hadoop.fs.Path getExternalTmpPath(URI extURI)
          Get a path to store tmp data destined for external URI.
 org.apache.hadoop.fs.Path getExtTmpPathRelTo(URI uri)
          This is similar to getExternalTmpPath() with difference being this method returns temp path within passed in uri, whereas getExternalTmpPath() ignores passed in path and returns temp path within /tmp
 List<HiveLock> getHiveLocks()
           
 HiveTxnManager getHiveTxnManager()
           
 Map<LoadTableDesc,WriteEntity> getLoadTableOutputMap()
           
 org.apache.hadoop.fs.Path getLocalScratchDir(boolean mkdir)
          Create a local scratch directory on demand and return it.
 org.apache.hadoop.fs.Path getLocalTmpPath()
          Get a tmp path on local host to store intermediate data.
 org.apache.hadoop.fs.Path getMRScratchDir()
          Create a map-reduce scratch directory on demand and return it.
 org.apache.hadoop.fs.Path getMRTmpPath()
          Get a path to store map-reduce intermediate data in.
 Map<WriteEntity,List<HiveLockObj>> getOutputLockObjects()
           
 Map<String,org.apache.hadoop.fs.ContentSummary> getPathToCS()
           
 org.apache.hadoop.fs.Path getResDir()
           
 org.apache.hadoop.fs.Path getResFile()
           
 DataInput getStream()
           
 org.antlr.runtime.TokenRewriteStream getTokenRewriteStream()
           
 int getTryCount()
           
 boolean isHDFSCleanup()
           
 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 for intermediate data
 boolean isNeedLockMgr()
           
 void resetStream()
           
 void restoreOriginalTracker()
           
 void setCmd(String cmd)
          Set the original query command.
 void setExplain(boolean value)
          Set the context on whether the current query is an explain query.
 void setExplainLogical(boolean explainLogical)
          Set the context on whether the current query is a logical explain query.
 void setHDFSCleanup(boolean isHDFSCleanup)
           
 void setHiveLocks(List<HiveLock> hiveLocks)
           
 void setHiveTxnManager(HiveTxnManager txnMgr)
           
 void setNeedLockMgr(boolean needLockMgr)
           
 void setOriginalTracker(String originalTracker)
           
 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.
 void setTryCount(int tryCount)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context(org.apache.hadoop.conf.Configuration conf)
        throws IOException
Throws:
IOException

Context

public Context(org.apache.hadoop.conf.Configuration conf,
               String executionId)
Create a Context with a given executionId. ExecutionId, together with user name and conf, will determine the temporary directory locations.

Method Detail

getLoadTableOutputMap

public Map<LoadTableDesc,WriteEntity> getLoadTableOutputMap()

getOutputLockObjects

public Map<WriteEntity,List<HiveLockObj>> getOutputLockObjects()

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 whether the current query is an explain query

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

getExplainLogical

public boolean getExplainLogical()
Find whether the current query is a logical explain query


setExplainLogical

public void setExplainLogical(boolean explainLogical)
Set the context on whether the current query is a logical explain query.


setCmd

public void setCmd(String cmd)
Set the original query command.

Parameters:
cmd - the original query command string

getCmd

public String getCmd()
Find the original query command.

Returns:
the original query command string

getLocalScratchDir

public org.apache.hadoop.fs.Path getLocalScratchDir(boolean mkdir)
Create a local scratch directory on demand and return it.


getMRScratchDir

public org.apache.hadoop.fs.Path getMRScratchDir()
Create a map-reduce scratch directory on demand and return it.


isMRTmpFileURI

public boolean isMRTmpFileURI(String uriStr)
Check if path is for intermediate data

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

getMRTmpPath

public org.apache.hadoop.fs.Path getMRTmpPath()
Get a path to store map-reduce intermediate data in.

Returns:
next available path for map-red intermediate data

getLocalTmpPath

public org.apache.hadoop.fs.Path getLocalTmpPath()
Get a tmp path on local host to store intermediate data.

Returns:
next available tmp path on local fs

getExternalTmpPath

public org.apache.hadoop.fs.Path getExternalTmpPath(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

getExtTmpPathRelTo

public org.apache.hadoop.fs.Path getExtTmpPathRelTo(URI uri)
This is similar to getExternalTmpPath() with difference being this method returns temp path within passed in uri, whereas getExternalTmpPath() ignores passed in path and returns temp path within /tmp


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()

resetStream

public void resetStream()

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.


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


getHiveLocks

public List<HiveLock> getHiveLocks()

setHiveLocks

public void setHiveLocks(List<HiveLock> hiveLocks)

getHiveTxnManager

public HiveTxnManager getHiveTxnManager()

setHiveTxnManager

public void setHiveTxnManager(HiveTxnManager txnMgr)

setOriginalTracker

public void setOriginalTracker(String originalTracker)

restoreOriginalTracker

public void restoreOriginalTracker()

addCS

public void addCS(String path,
                  org.apache.hadoop.fs.ContentSummary cs)

getCS

public org.apache.hadoop.fs.ContentSummary getCS(org.apache.hadoop.fs.Path path)

getCS

public org.apache.hadoop.fs.ContentSummary getCS(String path)

getPathToCS

public Map<String,org.apache.hadoop.fs.ContentSummary> getPathToCS()

getConf

public org.apache.hadoop.conf.Configuration getConf()

isHDFSCleanup

public boolean isHDFSCleanup()
Returns:
the isHDFSCleanup

setHDFSCleanup

public void setHDFSCleanup(boolean isHDFSCleanup)
Parameters:
isHDFSCleanup - the isHDFSCleanup to set

isNeedLockMgr

public boolean isNeedLockMgr()

setNeedLockMgr

public void setNeedLockMgr(boolean needLockMgr)

getTryCount

public int getTryCount()

setTryCount

public void setTryCount(int tryCount)


Copyright © 2014 The Apache Software Foundation. All rights reserved.