Last active
December 18, 2015 10:09
-
-
Save folone/5766269 to your computer and use it in GitHub Desktop.
Parallelizing lazy Streams.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final val BATCH_SIZE = (Runtime.getRuntime.freeMemory / 1024).toInt // kb per object should be enough, right? | |
def doStuff(m: MyType): Stream[MyType] = ??? // Costly operation | |
val s: Stream[MyType] = ??? | |
s.grouped(BATCH_SIZE).toStream.flatMap(_.par flatMap doStuff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment