This file contains hidden or 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 org.rogach.scallop._ | |
import org.scalatest.FunSuite | |
import org.scalatest.matchers.ShouldMatchers | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Alexy | |
* Date: 4/6/12 | |
* Time: 10:34 AM |
This file contains hidden or 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
(dateOpt, oldRankerPairsFileOpt) match { | |
case (Some(_),Some(_)) => Console.err.println("You gave both a date and the previous ranker-pairs file. Good.") | |
case (None, None) => // nothin' is nothin' is nothin' | |
case _ => sys.error("You have to give an old ranker-pairs file for a date, and vice versa. Bad.") | |
} |
This file contains hidden or 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 org.rogach.scallop._ | |
import org.scalatest.FunSuite | |
import org.scalatest.matchers.ShouldMatchers | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Alexy | |
* Date: 4/6/12 | |
* Time: 10:34 AM |
This file contains hidden or 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
val soiBy1: DList[Edge] = | |
if (o.fromKey()) { | |
val soiByK: DList[String] = convertKeyFromSequenceFile(o.soiByFile()) | |
soiByK map { k => val c = k.split(","); (c(4).toLong, c(1).toLong) } | |
} | |
else fromDelimitedTextFile(o.soiByFile(),o.sep) { | |
case Long(u) :: Long(v) :: _ => (u,v) | |
} | |
val soiBy2: DList[Edge] = if (o.flip()) soiBy1 ++ soiBy1.map(_.swap) else soiBy1 |
This file contains hidden or 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
def putStat[T](id: String, k: String, v: T, coll: MongoCollection = ms): Unit = { | |
Console.err.println("putting mongo stat: _id->%s, %s->%s".format(id,k,v)) | |
val newVal = Map(k -> v) | |
coll.findOneByID(id) match { | |
case Some(obj) => coll.update(obj, obj + (k -> v)) | |
case _ => coll.insert(MongoDBObject("_id"->id, k->v)) | |
} | |
} |
This file contains hidden or 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
©2012 Viktor Klang | |
object Actor { | |
import java.util.concurrent.{ConcurrentLinkedQueue, Executor} | |
import java.util.concurrent.atomic.{AtomicBoolean} | |
type Behavior = Any => Effect | |
sealed trait Effect { def getOrElse(old: Behavior): Behavior } | |
case object Stay extends Effect { def getOrElse(old: Behavior): Behavior = old } | |
case class Become(like: Behavior) extends Effect { def getOrElse(old: Behavior): Behavior = like } |
This file contains hidden or 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
def array2Pair(a: Array[String]): UserScore = { | |
if (a.size != 2) throw new NotArray2 | |
(a(0).toLong, a(1).toDouble) | |
} | |
io.Source.fromFile(fileName).getLines().map(_.split("\t")).map(array2Pair(_)) |
This file contains hidden or 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
def readUserScores(fileName: String): List[UserScore] = { | |
val serocs = ((Nil: List[UserScore]) /: | |
io.Source.fromFile(fileName).getLines() | |
// .map(_.split("\t")).map(array2Pair(_)) | |
// .map(((x:String) => x.split("\t")) andThen array2Pair) | |
// .map(((_:String).split("\t")) andThen array2Pair) | |
.map( array2Pair _ compose (_.split("\t"))) | |
) { case (l, e) => e :: l } | |
serocs.reverse |
This file contains hidden or 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
object PairsNews { | |
type RankerPairs = DList[(Long, Iterable[(Long, Long))] | |
def main(a: Array[String]) = withHadoopArgs(a) { case args => | |
case object o extends ScallopConf(args) { | |
val date = opt[String]("date", descr = "generate pairs for new regs after that date") | |
val allRankerPairsBase = opt[String]("base", descr = "directory where all ranker-pairs are stored, per day", | |
default = Some("fatpipe/generated")) |
This file contains hidden or 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 sbt._ | |
import Keys._ | |
object MyBuild extends Build { | |
lazy val copyDependencies = TaskKey[Unit]("copy-dependencies") | |
def copyDepTask = copyDependencies <<= (update, crossTarget, scalaVersion) map { | |
(updateReport, out, scalaVer) => | |
updateReport.allFiles foreach { srcPath => |