danneu
02/11/2017, 6:00 AMfun <T> Iterable<T>.batch(chunkSize: Int) = this
.mapIndexed { i, item -> i to item }. // create index value pairs
.groupBy { it.first / chunkSize }. // create grouping index
.map { it.value.map { it.second } } // split into different partitions
max.cruz
02/11/2017, 5:07 PM