|
Spring for Apache Hadoop | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.hadoop.hive.HiveTemplate
public class HiveTemplate
Helper class that simplifies Hive data access code. Automatically handles the creation of a HiveClient
(which is non-thread-safe)
and converts Hive exceptions into DataAccessExceptions.
Constructor Summary | |
---|---|
HiveTemplate()
Constructs a new HiveClient instance. |
|
HiveTemplate(HiveClientFactory hiveClientFactory)
Constructs a new HiveTemplate instance. |
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
protected org.springframework.dao.DataAccessException |
convertHiveAccessException(java.lang.Exception ex)
Converts the given Hive exception to an appropriate exception from the org.springframework.dao hierarchy. |
|
protected org.apache.hadoop.hive.service.HiveClient |
createHiveClient()
|
|
|
execute(HiveClientCallback<T> action)
Executes the action specified by the given callback object within an active HiveClient . |
|
java.util.List<java.lang.String> |
executeScript(HiveScript script)
Executes a Hive script. |
|
java.util.List<java.lang.String> |
executeScript(java.lang.Iterable<HiveScript> scripts)
Executes multiple Hive scripts. |
|
java.util.List<java.lang.String> |
query(java.lang.String query)
Executes the given HiveQL that results in a list of objects. |
|
java.util.List<java.lang.String> |
query(java.lang.String query,
java.util.Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, expecting a list of objects. |
|
java.lang.Integer |
queryForInt(java.lang.String query)
Executes the given HiveQL that results in a single int value. |
|
java.lang.Integer |
queryForInt(java.lang.String query,
java.util.Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, that results in a single int value. |
|
java.lang.Long |
queryForLong(java.lang.String query)
Executes the given HiveQL that results in a single long value. |
|
java.lang.Long |
queryForLong(java.lang.String query,
java.util.Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, that results in a single long value. |
|
java.lang.String |
queryForString(java.lang.String query)
Executes the given HiveQL that results in a single object. |
|
java.lang.String |
queryForString(java.lang.String query,
java.util.Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, that results in a single object. |
|
void |
setHiveClientFactory(HiveClientFactory hiveClientFactory)
Sets the HiveClient factory. |
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HiveTemplate()
HiveClient
instance.
Expects setHiveClientFactory(HiveClientFactory)
to be called before using it.
public HiveTemplate(HiveClientFactory hiveClientFactory)
HiveTemplate
instance.
hiveClientFactory
- HiveClient factoryMethod Detail |
---|
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public <T> T execute(HiveClientCallback<T> action) throws org.springframework.dao.DataAccessException
HiveClient
.
execute
in interface HiveOperations
action
- callback object that specifies the Hive action
org.springframework.dao.DataAccessException
protected org.springframework.dao.DataAccessException convertHiveAccessException(java.lang.Exception ex)
ex
- hive exception
public java.util.List<java.lang.String> query(java.lang.String query) throws org.springframework.dao.DataAccessException
query
in interface HiveOperations
query
- HiveQL
org.springframework.dao.DataAccessException
public java.util.List<java.lang.String> query(java.lang.String query, java.util.Map<?,?> arguments) throws org.springframework.dao.DataAccessException
query
in interface HiveOperations
query
- HiveQLarguments
- query arguments
org.springframework.dao.DataAccessException
public java.lang.String queryForString(java.lang.String query) throws org.springframework.dao.DataAccessException
queryForString
in interface HiveOperations
query
- HiveQL
org.springframework.dao.DataAccessException
public java.lang.String queryForString(java.lang.String query, java.util.Map<?,?> arguments) throws org.springframework.dao.DataAccessException
queryForString
in interface HiveOperations
query
- HiveQLarguments
- query arguments
org.springframework.dao.DataAccessException
public java.lang.Integer queryForInt(java.lang.String query) throws org.springframework.dao.DataAccessException
queryForInt
in interface HiveOperations
query
- HiveQL
org.springframework.dao.DataAccessException
public java.lang.Integer queryForInt(java.lang.String query, java.util.Map<?,?> arguments) throws org.springframework.dao.DataAccessException
queryForInt
in interface HiveOperations
query
- HiveQLarguments
- query arguments
org.springframework.dao.DataAccessException
public java.lang.Long queryForLong(java.lang.String query) throws org.springframework.dao.DataAccessException
queryForLong
in interface HiveOperations
query
- HiveQL
org.springframework.dao.DataAccessException
public java.lang.Long queryForLong(java.lang.String query, java.util.Map<?,?> arguments) throws org.springframework.dao.DataAccessException
queryForLong
in interface HiveOperations
query
- HiveQLarguments
- query arguments
org.springframework.dao.DataAccessException
public java.util.List<java.lang.String> executeScript(HiveScript script) throws org.springframework.dao.DataAccessException
executeScript
in interface HiveOperations
script
- script resource and arguments
org.springframework.dao.DataAccessException
public java.util.List<java.lang.String> executeScript(java.lang.Iterable<HiveScript> scripts) throws org.springframework.dao.DataAccessException
executeScript
in interface HiveOperations
scripts
- scripts resources and arguments
org.springframework.dao.DataAccessException
protected org.apache.hadoop.hive.service.HiveClient createHiveClient()
public void setHiveClientFactory(HiveClientFactory hiveClientFactory)
HiveClient
factory.
hiveClientFactory
- hive client factory to setpublic void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader
in interface org.springframework.context.ResourceLoaderAware
|
Spring for Apache Hadoop | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |