Enum Class BaseStream.Splitor

java.lang.Object
java.lang.Enum<BaseStream.Splitor>
com.landawn.abacus.util.stream.BaseStream.Splitor
All Implemented Interfaces:
Serializable, Comparable<BaseStream.Splitor>, Constable
Enclosing interface:
BaseStream<T,A,P,C,PL,OT,IT,ITER extends Iterator<T>,S extends BaseStream<T,A,P,C,PL,OT,IT,ITER,S>>

public static enum BaseStream.Splitor extends Enum<BaseStream.Splitor>
Generally, or most of time, elements will be fetched and processed by parallel threads one by one.
 synchronized (elements) {
    if (elements.hasNext()) {
       next = elements.next();
    }
 }

 // Do something with next...
 
Splitor.ARRAY only works when stream elements are stored in an array. The array will be equally split into slices based on thread number for each thread:
 int sliceSize = (toIndex - fromIndex) / threadNum + ((toIndex - fromIndex) % threadNum == 0 ? 0 : 1);
 
If stream elements are not stored in an array, Splitor.ARRAY will just works as same as how Splitor.ITERATOR works.

If you want to customize the buffer size for each thread, try stream.split(bufferSize) or stream.splitToList(bufferSize)
 stream.split(bufferSize).parallel(...).map/filter/flatMap...(sliceStream -> // do whatever you want to do);
 stream.splitToList(bufferSize).parallel(...).map/filter/flatMap...(sliceList -> // do whatever you want to do);
 // Or
 stream.sps(maxThreadNum, bufferSize, op)
 
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static BaseStream.Splitor[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BaseStream.Splitor valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null