Spring for Apache Hadoop

org.springframework.data.hadoop.store.dataset
Class DatasetTemplate

java.lang.Object
  extended by org.springframework.data.hadoop.store.dataset.DatasetTemplate
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, DatasetOperations

public class DatasetTemplate
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, DatasetOperations

This is the central class in the store.dataset package. It simplifies the use of Datasets, DatasetReaders and DatasetWriters

Since:
2.0
Author:
Thomas Risberg

Constructor Summary
DatasetTemplate()
           
 
Method Summary
 void afterPropertiesSet()
           
 void execute(DatasetRepositoryCallback callback)
          Execute a callback for the DatasetRepository
<T> java.lang.String
getDatasetName(java.lang.Class<T> clazz)
          Get the dataset name to be used for the given class
 DatasetDefinition getDefaultDatasetDefinition()
          The default DatasetDefinition to use for this template.
<T> java.util.Collection<T>
read(java.lang.Class<T> targetClass)
          Read all records in the dataset and return as a collection.
<T> void
read(java.lang.Class<T> targetClass, RecordCallback<T> callback)
          Read all records in the dataset and call the provided callback for each record.
 void setDatasetRepositoryFactory(DatasetRepositoryFactory datasetRepositoryFactory)
          The DatasetRepositoryFactory to use for this template.
 void setDefaultDatasetDefinition(DatasetDefinition defaultDatasetDefinition)
          The default DatasetDefinition to use for this template.
<T> void
write(java.util.Collection<T> records)
          Write all records provided in the record collection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetTemplate

public DatasetTemplate()
Method Detail

setDatasetRepositoryFactory

public void setDatasetRepositoryFactory(DatasetRepositoryFactory datasetRepositoryFactory)
The DatasetRepositoryFactory to use for this template.

Parameters:
datasetRepositoryFactory - the DatasetRepositoryFactory to use

getDefaultDatasetDefinition

public DatasetDefinition getDefaultDatasetDefinition()
The default DatasetDefinition to use for this template.


setDefaultDatasetDefinition

public void setDefaultDatasetDefinition(DatasetDefinition defaultDatasetDefinition)
The default DatasetDefinition to use for this template.

Parameters:
defaultDatasetDefinition - the DatasetDefinition to use

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

read

public <T> void read(java.lang.Class<T> targetClass,
                     RecordCallback<T> callback)
Description copied from interface: DatasetOperations
Read all records in the dataset and call the provided callback for each record.

Specified by:
read in interface DatasetOperations
Parameters:
targetClass - the class that is stored in the dataset
callback - the callback to be called for each record

read

public <T> java.util.Collection<T> read(java.lang.Class<T> targetClass)
Description copied from interface: DatasetOperations
Read all records in the dataset and return as a collection.

Specified by:
read in interface DatasetOperations
Parameters:
targetClass - the class that is stored in the dataset
Returns:
collection containing the records as the specified target class

write

public <T> void write(java.util.Collection<T> records)
Description copied from interface: DatasetOperations
Write all records provided in the record collection

Specified by:
write in interface DatasetOperations
Parameters:
records - the records to write

execute

public void execute(DatasetRepositoryCallback callback)
Description copied from interface: DatasetOperations
Execute a callback for the DatasetRepository

Specified by:
execute in interface DatasetOperations

getDatasetName

public <T> java.lang.String getDatasetName(java.lang.Class<T> clazz)
Description copied from interface: DatasetOperations
Get the dataset name to be used for the given class

Specified by:
getDatasetName in interface DatasetOperations
Parameters:
clazz - the class stored in the dataset
Returns:
the dataset name

Spring for Apache Hadoop