Class JobBatch

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class JobBatch
    extends Object
    implements Serializable, Cloneable
    Simple convenience input for splitting deterministically-ordered jobs and processing them in chunks based on their position in the list.
    Sina Madani
    See Also:
    Serialized Form
    • Field Detail

      • from

        public int from
        The start index.
      • to

        public int to
        The end index.
    • Constructor Detail

      • JobBatch

        public JobBatch()
      • JobBatch

        public JobBatch​(int from,
                        int to)
    • Method Detail

      • hashCode

        public int hashCode()
        hashCode in class Object
      • getBatches

        public static List<JobBatch> getBatches​(int totalJobs,
                                                int chunks)
        Provides a List of indices based on the desired split size.
        totalJobs - The size of the source List being split
        chunks - The range (i.e. to - from) of each batch. The last batch may be smaller than this but the other batches are guaranteed to be of this size.
        A Serializable List of indexes with totalJobs/batches increments.
      • splitToList

        public <T> List<T> splitToList​(T[] arr)
      • split

        public <T> T[] split​(T[] arr)
      • split

        public <T> List<T> split​(List<T> list)
        Splits the given list based on this class's indices.
        Type Parameters:
        T - The type of the List
        list - The list to call List.subList(int, int) on
        The split list.