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

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

public class DatasetTemplate
extends Object
implements 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
 Collection<DatasetDefinition> getDatasetDefinitions()
          The DatasetDefinitions used for this template.
<T> org.kitesdk.data.DatasetDescriptor
getDatasetDescriptor(Class<T> targetClass)
          Get the DatasetDescriptor for the given class
<T> String
getDatasetName(Class<T> clazz)
          Get the dataset name to be used for the given class
 DatasetDefinition getDefaultDatasetDefinition()
          The default DatasetDefinition used for this template.
<T> Collection<T>
read(Class<T> targetClass)
          Read all records in the dataset and return as a collection.
<T> Collection<T>
read(Class<T> targetClass, org.kitesdk.data.PartitionKey partitionKey)
          Read records in the dataset partition based on the PartitionKey and return as a collection.
<T> void
read(Class<T> targetClass, RecordCallback<T> callback)
          Read all records in the dataset and call the provided callback for each record.
<T> void
read(Class<T> targetClass, RecordCallback<T> callback, org.kitesdk.data.PartitionKey partitionKey)
          Read records in the dataset partition based on the PartitionKey and call the provided callback for each record.
 void setDatasetDefinitions(Collection<DatasetDefinition> datasetDefinitions)
          The list of DatasetDefinitions to use for this template.
 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(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 used for this template.


setDefaultDatasetDefinition

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

Parameters:
defaultDatasetDefinition - the DatasetDefinition to use

getDatasetDefinitions

public Collection<DatasetDefinition> getDatasetDefinitions()
The DatasetDefinitions used for this template.


setDatasetDefinitions

public void setDatasetDefinitions(Collection<DatasetDefinition> datasetDefinitions)
The list of DatasetDefinitions to use for this template.

Parameters:
datasetDefinitions - the DatasetDefinitions to use

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

read

public <T> void read(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> Collection<T> read(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

read

public <T> void read(Class<T> targetClass,
                     RecordCallback<T> callback,
                     org.kitesdk.data.PartitionKey partitionKey)
Description copied from interface: DatasetOperations
Read records in the dataset partition based on the PartitionKey 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
partitionKey - the partition key to use for the read

read

public <T> Collection<T> read(Class<T> targetClass,
                              org.kitesdk.data.PartitionKey partitionKey)
Description copied from interface: DatasetOperations
Read records in the dataset partition based on the PartitionKey and return as a collection.

Specified by:
read in interface DatasetOperations
Parameters:
targetClass - the class that is stored in the dataset
partitionKey - the partition key to use for the read
Returns:
collection containing the records as the specified target class

write

public <T> void write(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

getDatasetDescriptor

public <T> org.kitesdk.data.DatasetDescriptor getDatasetDescriptor(Class<T> targetClass)
Description copied from interface: DatasetOperations
Get the DatasetDescriptor for the given class

Specified by:
getDatasetDescriptor in interface DatasetOperations
Parameters:
targetClass - the class stored in the dataset
Returns:
the DatasetDescriptor

getDatasetName

public <T> String getDatasetName(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