Class ColumnRangePartitioner
- java.lang.Object
- org.springframework.batch.sample.common.ColumnRangePartitioner
- All Implemented Interfaces:
Partitioner
public class ColumnRangePartitioner extends java.lang.Object implements Partitioner
Simple minded partitioner for a range of values of a column in a database table. Works best if the values are uniformly distributed (e.g. auto-generated primary key values).- Author:
- Dave Syer
Constructor Summary
Constructors Constructor Description ColumnRangePartitioner()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,ExecutionContext>
partition(int gridSize)
Partition a database table assuming that the data in the column specified are uniformly distributed.void
setColumn(java.lang.String column)
The name of the column to partition.void
setDataSource(javax.sql.DataSource dataSource)
The data source for connecting to the database.void
setTable(java.lang.String table)
The name of the SQL table the data are in.
Method Detail
setTable
public void setTable(java.lang.String table)
The name of the SQL table the data are in.- Parameters:
table
- the name of the table
setColumn
public void setColumn(java.lang.String column)
The name of the column to partition.- Parameters:
column
- the column name.
setDataSource
public void setDataSource(javax.sql.DataSource dataSource)
The data source for connecting to the database.- Parameters:
dataSource
- aDataSource
partition
public java.util.Map<java.lang.String,ExecutionContext> partition(int gridSize)
Partition a database table assuming that the data in the column specified are uniformly distributed. The execution context values will have keysminValue
andmaxValue
specifying the range of values to consider in each partition.- Specified by:
partition
in interfacePartitioner
- Parameters:
gridSize
- the size of the map to return- Returns:
- a map from identifier to input parameters
- See Also:
Partitioner.partition(int)