|
|||||||||
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 DataAccessException |
convertHiveAccessException(Exception ex)
Converts the given Hive exception to an appropriate exception from the org.springframework.dao hierarchy. |
|
protected HiveClient |
createHiveClient()
|
|
|
execute(HiveClientCallback<T> action)
Executes the action specified by the given callback object within an active HiveClient . |
|
List<String> |
executeScript(HiveScript script)
Executes a Hive script. |
|
List<String> |
executeScript(Iterable<HiveScript> scripts)
Executes multiple Hive scripts. |
|
List<String> |
query(String query)
Executes the given HiveQL that results in a list of objects. |
|
List<String> |
query(String query,
Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, expecting a list of objects. |
|
Integer |
queryForInt(String query)
Executes the given HiveQL that results in a single int value. |
|
Integer |
queryForInt(String query,
Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, that results in a single int value. |
|
Long |
queryForLong(String query)
Executes the given HiveQL that results in a single long value. |
|
Long |
queryForLong(String query,
Map<?,?> arguments)
Executes the given HiveQL using the list of arguments, that results in a single long value. |
|
String |
queryForString(String query)
Executes the given HiveQL that results in a single object. |
|
String |
queryForString(String query,
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(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 InitializingBean
public <T> T execute(HiveClientCallback<T> action) throws DataAccessException
HiveClient
.
execute
in interface HiveOperations
action
- callback object that specifies the Hive action
DataAccessException
protected DataAccessException convertHiveAccessException(Exception ex)
ex
- hive exception
public List<String> query(String query) throws DataAccessException
query
in interface HiveOperations
query
- HiveQL
DataAccessException
public List<String> query(String query, Map<?,?> arguments) throws DataAccessException
query
in interface HiveOperations
query
- HiveQLarguments
- query arguments
DataAccessException
public String queryForString(String query) throws DataAccessException
queryForString
in interface HiveOperations
query
- HiveQL
DataAccessException
public String queryForString(String query, Map<?,?> arguments) throws DataAccessException
queryForString
in interface HiveOperations
query
- HiveQLarguments
- query arguments
DataAccessException
public Integer queryForInt(String query) throws DataAccessException
queryForInt
in interface HiveOperations
query
- HiveQL
DataAccessException
public Integer queryForInt(String query, Map<?,?> arguments) throws DataAccessException
queryForInt
in interface HiveOperations
query
- HiveQLarguments
- query arguments
DataAccessException
public Long queryForLong(String query) throws DataAccessException
queryForLong
in interface HiveOperations
query
- HiveQL
DataAccessException
public Long queryForLong(String query, Map<?,?> arguments) throws DataAccessException
queryForLong
in interface HiveOperations
query
- HiveQLarguments
- query arguments
DataAccessException
public List<String> executeScript(HiveScript script) throws DataAccessException
executeScript
in interface HiveOperations
script
- script resource and arguments
DataAccessException
public List<String> executeScript(Iterable<HiveScript> scripts) throws DataAccessException
executeScript
in interface HiveOperations
scripts
- scripts resources and arguments
DataAccessException
protected HiveClient createHiveClient()
public void setHiveClientFactory(HiveClientFactory hiveClientFactory)
HiveClient
factory.
hiveClientFactory
- hive client factory to setpublic void setResourceLoader(ResourceLoader resourceLoader)
setResourceLoader
in interface ResourceLoaderAware
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |