Created
May 13, 2012 19:37
-
-
Save worthlesscog/2689887 to your computer and use it in GitHub Desktop.
Convert numbered 3 digit chunks and stack them for later
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.Actor.self | |
import scala.actors.remote.RemoteActor.{ select, register, alive } | |
import scala.actors.remote.Node | |
import scala.actors.Actor | |
import scala.collection.mutable.Map | |
import NumberText1.conv | |
object Mapper { | |
def main(args: Array[String]) { | |
println("Mapper running") | |
val actor = new Actor { | |
def act { | |
alive(System.getProperty("port").toInt) | |
register('mapper, self) | |
val map = Map[Int, String]() | |
val reducer = select(Node("localhost", System.getProperty("reducer").toInt), 'reducer) | |
loop { | |
receive { | |
case (k: Int, n: Int) ⇒ println("Received " + n); map += (k -> conv(n)) | |
case "Done" ⇒ println("Sending " + map); reducer ! map; exit | |
} | |
} | |
} | |
} | |
actor.start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment