Created
May 13, 2012 19:24
-
-
Save worthlesscog/2689856 to your computer and use it in GitHub Desktop.
Decimal number reader and splitter
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
import scala.actors.remote.RemoteActor.select | |
import scala.actors.remote.Node | |
import scala.actors.Actor | |
object Reader { | |
def main(args: Array[String]) { | |
println("Reader running") | |
val actor = new Actor { | |
def act() { | |
val mappers = System.getProperty("mappers").split(",").map(m ⇒ select(Node("localhost", m.toInt), 'mapper)) | |
var n = System.getProperty("number").toInt | |
var m = 0 | |
do { | |
mappers(m % mappers.size) ! (m, n % 1000) | |
m += 1 | |
n /= 1000 | |
} while (n > 0) | |
mappers.foreach(_ ! "Done") | |
} | |
} | |
actor.start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment