org.apache.lens.driver.hive
Class HiveDriver

java.lang.Object
  extended by org.apache.lens.driver.hive.HiveDriver
All Implemented Interfaces:
Externalizable, Serializable, LensDriver

public class HiveDriver
extends Object
implements LensDriver

The Class HiveDriver.

See Also:
Serialized Form

Field Summary
static float DAILY_PARTITION_WEIGHT_DEFAULT
           
static long DEFAULT_EXPIRY_DELAY
           
static String HIVE_CONNECTION_CLASS
          The Constant HIVE_CONNECTION_CLASS.
static float HOURLY_PARTITION_WEIGHT_DEFAULT
           
static String HS2_CALCULATE_PRIORITY
           
static String HS2_CONNECTION_EXPIRY_DELAY
          The Constant HS2_CONNECTION_EXPIRY_DELAY.
static String HS2_PARTITION_WEIGHT_DAILY
           
static String HS2_PARTITION_WEIGHT_HOURLY
           
static String HS2_PARTITION_WEIGHT_MONTHLY
           
static String HS2_PRIORITY_DEFAULT_RANGES
           
static String HS2_PRIORITY_RANGES
          Config param for defining priority ranges.
static org.apache.log4j.Logger LOG
          The Constant LOG.
static float MONTHLY_PARTITION_WEIGHT_DEFAULT
           
 
Constructor Summary
HiveDriver()
          Instantiates a new hive driver.
 
Method Summary
 boolean areRsourcesAddedForSession(String sessionHandle)
          Return true if resources have been added to this Hive session
 boolean cancelQuery(QueryHandle handle)
          Cancel the execution of the query, specified by the handle.
 void close()
          Close the driver, releasing all resouces used up by the driver.
 void closePreparedQuery(QueryPrepareHandle handle)
          Close the prepare query specified by the prepared handle, releases all the resources held by the prepared query.
 void closeQuery(QueryHandle handle)
          Close the query specified by the handle, releases all the resources held by the query.
 void closeResultSet(QueryHandle handle)
          Close the resultset for the query.
 void closeSession(LensSessionHandle sessionHandle)
          Close session.
 void configure(org.apache.hadoop.conf.Configuration conf)
          Configure driver with Configuration passed.
 QueryCost estimate(AbstractQueryContext qctx)
          Estimate the cost of execution for given query.
 LensResultSet execute(QueryContext ctx)
          Blocking execute of the query

The driver would be closing the driver handle, once the results are fetched.

 void executeAsync(QueryContext ctx)
          Asynchronously execute the query.
 HiveQueryPlan explain(AbstractQueryContext explainCtx)
          Explain the given query.
 DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext)
          Explain and prepare the given query.
 LensResultSet fetchResultSet(QueryContext ctx)
          Fetch the results of the query, specified by the handle.
 org.apache.hadoop.conf.Configuration getConf()
          Get driver configuration
 boolean hasLensSession(LensSessionHandle session)
          Checks for lens session.
 void prepare(PreparedQueryContext pContext)
          Prepare the given query.
 void readExternal(ObjectInput in)
           
 void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener)
          Add a listener for driver events.
 void registerForCompletionNotification(QueryHandle handle, long timeoutMillis, QueryCompletionListener listener)
          Register for query completion notification.
 void setResourcesAddedForSession(String sessionHandle)
          Tell Hive driver that resources have been added for this session
 void updateStatus(QueryContext context)
          Update driver query status in the context object.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
The Constant LOG.


HIVE_CONNECTION_CLASS

public static final String HIVE_CONNECTION_CLASS
The Constant HIVE_CONNECTION_CLASS.

See Also:
Constant Field Values

HS2_CONNECTION_EXPIRY_DELAY

public static final String HS2_CONNECTION_EXPIRY_DELAY
The Constant HS2_CONNECTION_EXPIRY_DELAY.

See Also:
Constant Field Values

HS2_CALCULATE_PRIORITY

public static final String HS2_CALCULATE_PRIORITY
See Also:
Constant Field Values

HS2_PRIORITY_RANGES

public static final String HS2_PRIORITY_RANGES
Config param for defining priority ranges.

See Also:
Constant Field Values

HS2_PARTITION_WEIGHT_MONTHLY

public static final String HS2_PARTITION_WEIGHT_MONTHLY
See Also:
Constant Field Values

HS2_PARTITION_WEIGHT_DAILY

public static final String HS2_PARTITION_WEIGHT_DAILY
See Also:
Constant Field Values

HS2_PARTITION_WEIGHT_HOURLY

public static final String HS2_PARTITION_WEIGHT_HOURLY
See Also:
Constant Field Values

DEFAULT_EXPIRY_DELAY

public static final long DEFAULT_EXPIRY_DELAY
See Also:
Constant Field Values

HS2_PRIORITY_DEFAULT_RANGES

public static final String HS2_PRIORITY_DEFAULT_RANGES
See Also:
Constant Field Values

MONTHLY_PARTITION_WEIGHT_DEFAULT

public static final float MONTHLY_PARTITION_WEIGHT_DEFAULT
See Also:
Constant Field Values

DAILY_PARTITION_WEIGHT_DEFAULT

public static final float DAILY_PARTITION_WEIGHT_DEFAULT
See Also:
Constant Field Values

HOURLY_PARTITION_WEIGHT_DEFAULT

public static final float HOURLY_PARTITION_WEIGHT_DEFAULT
See Also:
Constant Field Values
Constructor Detail

HiveDriver

public HiveDriver()
           throws LensException
Instantiates a new hive driver.

Throws:
LensException - the lens exception
Method Detail

areRsourcesAddedForSession

public boolean areRsourcesAddedForSession(String sessionHandle)
Return true if resources have been added to this Hive session

Parameters:
sessionHandle -
Returns:

setResourcesAddedForSession

public void setResourcesAddedForSession(String sessionHandle)
Tell Hive driver that resources have been added for this session

Parameters:
sessionHandle -

getConf

public org.apache.hadoop.conf.Configuration getConf()
Description copied from interface: LensDriver
Get driver configuration

Specified by:
getConf in interface LensDriver

configure

public void configure(org.apache.hadoop.conf.Configuration conf)
               throws LensException
Description copied from interface: LensDriver
Configure driver with Configuration passed.

Specified by:
configure in interface LensDriver
Parameters:
conf - The configuration object
Throws:
LensException - the lens exception

estimate

public QueryCost estimate(AbstractQueryContext qctx)
                   throws LensException
Description copied from interface: LensDriver
Estimate the cost of execution for given query. This should be returned with very less latency - should return within 10s of milli seconds.

Specified by:
estimate in interface LensDriver
Parameters:
qctx - The query context
Returns:
The QueryCost object
Throws:
LensException - the lens exception if driver cannot estimate

explain

public HiveQueryPlan explain(AbstractQueryContext explainCtx)
                      throws LensException
Description copied from interface: LensDriver
Explain the given query.

Specified by:
explain in interface LensDriver
Parameters:
explainCtx - The explain context
Returns:
The query plan object
Throws:
LensException - the lens exception

explainAndPrepare

public DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext)
                                  throws LensException
Description copied from interface: LensDriver
Explain and prepare the given query.

Specified by:
explainAndPrepare in interface LensDriver
Parameters:
pContext - the context
Returns:
The query plan object;
Throws:
LensException - the lens exception

prepare

public void prepare(PreparedQueryContext pContext)
             throws LensException
Description copied from interface: LensDriver
Prepare the given query.

Specified by:
prepare in interface LensDriver
Parameters:
pContext - the context
Throws:
LensException - the lens exception

closePreparedQuery

public void closePreparedQuery(QueryPrepareHandle handle)
                        throws LensException
Description copied from interface: LensDriver
Close the prepare query specified by the prepared handle, releases all the resources held by the prepared query.

Specified by:
closePreparedQuery in interface LensDriver
Parameters:
handle - The query handle
Throws:
LensException - the lens exception

execute

public LensResultSet execute(QueryContext ctx)
                      throws LensException
Description copied from interface: LensDriver
Blocking execute of the query

The driver would be closing the driver handle, once the results are fetched.

Specified by:
execute in interface LensDriver
Parameters:
ctx - the context
Returns:
returns the result set, null if there is no result available
Throws:
LensException - the lens exception

executeAsync

public void executeAsync(QueryContext ctx)
                  throws LensException
Description copied from interface: LensDriver
Asynchronously execute the query.

Specified by:
executeAsync in interface LensDriver
Parameters:
ctx - The query context
Throws:
LensException - the lens exception

updateStatus

public void updateStatus(QueryContext context)
                  throws LensException
Description copied from interface: LensDriver
Update driver query status in the context object.

Specified by:
updateStatus in interface LensDriver
Parameters:
context - The query context
Throws:
LensException - the lens exception

fetchResultSet

public LensResultSet fetchResultSet(QueryContext ctx)
                             throws LensException
Description copied from interface: LensDriver
Fetch the results of the query, specified by the handle.

Specified by:
fetchResultSet in interface LensDriver
Parameters:
ctx - The query context
Returns:
returns the result set
Throws:
LensException - the lens exception

closeResultSet

public void closeResultSet(QueryHandle handle)
                    throws LensException
Description copied from interface: LensDriver
Close the resultset for the query.

Specified by:
closeResultSet in interface LensDriver
Parameters:
handle - The query handle
Throws:
LensException - the lens exception

closeQuery

public void closeQuery(QueryHandle handle)
                throws LensException
Description copied from interface: LensDriver
Close the query specified by the handle, releases all the resources held by the query.

Specified by:
closeQuery in interface LensDriver
Parameters:
handle - The query handle
Throws:
LensException - the lens exception

cancelQuery

public boolean cancelQuery(QueryHandle handle)
                    throws LensException
Description copied from interface: LensDriver
Cancel the execution of the query, specified by the handle.

Specified by:
cancelQuery in interface LensDriver
Parameters:
handle - The query handle.
Returns:
true if cancel was successful, false otherwise
Throws:
LensException - the lens exception

close

public void close()
Description copied from interface: LensDriver
Close the driver, releasing all resouces used up by the driver.

Specified by:
close in interface LensDriver

registerDriverEventListener

public void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener)
Add a listener for driver events.

Specified by:
registerDriverEventListener in interface LensDriver
Parameters:
driverEventListener - the driver event listener

registerForCompletionNotification

public void registerForCompletionNotification(QueryHandle handle,
                                              long timeoutMillis,
                                              QueryCompletionListener listener)
                                       throws LensException
Description copied from interface: LensDriver
Register for query completion notification.

Specified by:
registerForCompletionNotification in interface LensDriver
Parameters:
handle - the handle
timeoutMillis - the timeout millis
listener - the listener
Throws:
LensException - the lens exception

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

closeSession

public void closeSession(LensSessionHandle sessionHandle)
Close session.

Parameters:
sessionHandle - the session handle

hasLensSession

public boolean hasLensSession(LensSessionHandle session)
Checks for lens session.

Parameters:
session - the session
Returns:
true, if successful


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.