in src/main/scala/com/twitter/stitch/Runner.scala [251:270]
def run(): Promise[K => Try[V]] = {
val max = maxSize
val f =
try {
if (keyCount <= max) { // since size <= maxSize there is at most 1 batch
val batch = new mutable.ArrayBuffer[K](keyCount)
keyBuckets.foreach { case (_, bucket) => bucket.forEach(k => batch += k) }
run(batch)
} else {
val batches = BatchPacking.packBatches(keyCount, keyBuckets, max, packingStrategy)
val keyChunks = batches.iterator
MapRunner.runBatches(run, keyChunks, maxConcurrency)
}
} catch {
case NonFatal(e) => Future.exception(e)
}
p.become(f)
p
}