public static <Req,Resp>List<Future<Resp>> executePartitioned(List<Req> requests,int parallelism,Function<List<Req>,Future<Resp>> executeBatch){
  MorePreconditions.checkNotBlank(requests);
  Preconditions.checkArgument(parallelism > 0);
  Preconditions.checkNotNull(executeBatch);
  int sizePerPartition=Math.max(requests.size() / parallelism,1);
  List<List<Req>> partitions=Lists.partition(requests,sizePerPartition);
  List<Future<Resp>> futures=Lists.newArrayListWithCapacity(partitions.size());
  for (  final List<Req> request : partitions) {
    futures.add(executeBatch.apply(request));
  }
  return futures;
}

public static < Req , Resp > List < Future < Resp > > executePartitioned ( List < Req > requests , int parallelism , Function < List < Req > , Future < Resp > > executeBatch ) { MorePreconditions . checkNotBlank ( requests ) ; Preconditions . checkArgument ( parallelism > 0 ) ; Preconditions . checkNotNull ( executeBatch ) ; int sizePerPartition = Math . max ( requests . size ( ) / parallelism , 1 ) ; List < List < Req > > partitions = Lists . partition ( requests , sizePerPartition ) ; List < Future < Resp > > futures = Lists . newArrayListWithCapacity ( partitions . size ( ) ) ; for ( final List < Req > request : partitions ) { futures . add ( executeBatch . apply ( request ) ) ; } return futures ; }
executes a batch of requests asynchronously in a partitioned manner , with the specified parallelism .
