gov.sandia.cognition.learning.data
Class SequentialDataMultiPartitioner

java.lang.Object
  extended by gov.sandia.cognition.learning.data.SequentialDataMultiPartitioner

public class SequentialDataMultiPartitioner
extends Object

This partitioner splits a Collection of data into a pre-defined number of approximately equal sequential partitions, with the nonzero remainder elements going into the final partition. For example, if we have ten data points in a Collection, and we want to split the Collection into three partitions, then the method will return three Collections

  1. : 1, 2, 3
  2. : 4, 5, 6
  3. : 7, 8, 9, 10

This is class was primarily intended for splitting datasets for parallelization.

Since:
2.1
Author:
Kevin R. Dixon

Constructor Summary
SequentialDataMultiPartitioner()
           
 
Method Summary
static
<DataType> ArrayList<ArrayList<DataType>>
create(Collection<? extends DataType> data, int numPartitions)
          Creates a partition of the given data into "numPartition" roughly equal sets, preserving their pre-existing sequential ordering, with the nonzero remainder elements going into the final partition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequentialDataMultiPartitioner

public SequentialDataMultiPartitioner()
Method Detail

create

public static <DataType> ArrayList<ArrayList<DataType>> create(Collection<? extends DataType> data,
                                                               int numPartitions)
Creates a partition of the given data into "numPartition" roughly equal sets, preserving their pre-existing sequential ordering, with the nonzero remainder elements going into the final partition.

Type Parameters:
DataType - Type of data to partition.
Parameters:
data - Collection of data to partition
numPartitions - Number of partitions to create.
Returns:
List of Lists of size data.size()/numPartitions, with the remainder of data elements going into the final partition.