Class JobBatch

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

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

      Fields 
      Modifier and Type Field Description
      int from
      The start index.
      int to
      The end index.
    • Constructor Summary

      Constructors 
      Constructor Description
      JobBatch()  
      JobBatch​(int from, int to)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected JobBatch clone()  
      boolean equals​(java.lang.Object obj)  
      static java.util.List<JobBatch> getBatches​(int totalJobs, int chunks)
      Provides a List of indices based on the desired split size.
      int hashCode()  
      <T> java.util.List<T> split​(java.util.List<T> list)
      Splits the given list based on this class's indices.
      <T> T[] split​(T[] arr)  
      <T> java.util.List<T> splitToList​(T[] arr)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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

      • clone

        protected JobBatch clone()
        Overrides:
        clone in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getBatches

        public static java.util.List<JobBatch> getBatches​(int totalJobs,
                                                          int chunks)
        Provides a List of indices based on the desired split size.
        Parameters:
        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.
        Returns:
        A Serializable List of indexes with totalJobs/batches increments.
      • splitToList

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

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

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