src/main/java/com/github/wnameless/io/reader/parallel/LineReaders.java
/**
   * Reads lines of content parallelly by dividing the input into smaller parts.
   * 
   * @param <E>
   *          the type of returning value
   * @param file
   *          which contents lines
   * @param maxLines
   *          the max number of lines of each parts
   * @param lineReaderFunction
   *          a function to process each part of the content which is read by a
   *          {@link LineReader}
   * @param executor
   *          a Java {@link Executor} to use
   * @return a list of {@link CompletableFuture}s
   * @throws IOException
   *           if any I/O Exception happened during reading
   */
Reads lines of content parallelly by dividing the input into smaller parts.


Reads lines of content parallelly by dividing the input into smaller parts .
public static <E> List<CompletableFuture<E>> readParallelly(File file,
      int maxLines, LineReaderFunction<E> lineReaderFunction, Executor executor)
      throws IOException {
    List<CompletableFuture<E>> futures = new ArrayList<>();
    List<Long> skipPoints = getPartitionPoints(file, maxLines);
    for (int i = 0; i < skipPoints.size(); i++) {
      int ii = i;
      CompletableFuture<E> future = CompletableFuture.supplyAsync(() -> {
        return lineReaderFunction.apply(ii,
            toLineReader(file, skipPoints.get(ii), maxLines));
      }, executor);
      futures.add(future);
    }
    return futures;
  }
public static < E > List < CompletableFuture < E > > readParallelly ( File file , int maxLines , LineReaderFunction < E > lineReaderFunction , Executor executor ) throws IOException { List < CompletableFuture < E > > futures = new ArrayList < > ( ) ; List < Long > skipPoints = getPartitionPoints ( file , maxLines ) ; for ( int i = 0 ; i < skipPoints . size ( ) ; i ++ ) { int ii = i ; CompletableFuture < E > future = CompletableFuture . supplyAsync ( ( ) -> { return lineReaderFunction . apply ( ii , toLineReader ( file , skipPoints . get ( ii ) , maxLines ) ) ; } , executor ) ; futures . add ( future ) ; } return futures ; }
Reads lines of content parallelly by dividing the input into smaller parts.
Reads lines of content parallelly by dividing the input into smaller parts .