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
case object o { | |
val suffix: Boolean = opts[Boolean]("suffix") | |
val csv: Boolean = opts[Boolean]("csv") | |
val minMax: Option[Int] = opts.get("min") | |
override def toString: String = | |
"\n"+ | |
"\n suffix=> " + suffix + | |
"\n csv => " + csv + | |
"\n minMax=> " + (minMax match { case Some(n) => n.toString; case _ => "nothing" }) |
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 printFileWriter(name: String): PrintWriter = { | |
new PrintWriter(new FileWriter(name)) | |
} | |
def writing[B](fileName: String)(f: PrintWriter => B): B = { | |
lazy val w = printFileWriter(fileName) // so throws only in try, if ever | |
try { f(w) } | |
finally { w.close() } | |
} |
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 com.mongodb.casbah._ | |
import org.joda.time.DateTime | |
import collection.mutable.ArrayBuffer | |
//... | |
def mongoGobble(co: Conf, chunk: List[Quad], globalIndex: Int) = { | |
val gobbles = chunk.zipWithIndex map { case ((x,y,r,ri),i) => | |
val n = globalIndex + i | |
val id = co.batch match { |
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 evenlyN[T](a: Array[T], n: Int): Array[T] = { | |
if (n < 1 || a.size < n) return a | |
val step = (a.size + 1) / n | |
val indices = (1 to n) map (_*step) | |
(indices map (a(_))).toArray | |
} | |
<console>:12: error: could not find implicit value for evidence parameter of type ClassManifest[T] | |
(indices map (a(_))).toArray |
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
sealed trait Response | |
case object Right extends Response | |
case object Wrong extends Response | |
case object Skip extends Response | |
case class Responses(right: Long = 0, wrong: Long = 0, skip: Long = 0) { | |
def apply(r: Response) = r match { | |
case Right => right | |
case Wrong => wrong | |
case Skip => skip |
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
package com.klout.labs.braver.util | |
import org.apache.hadoop.mapreduce.Job | |
import org.apache.hadoop.conf.Configuration | |
object Hadoop { | |
def setJobConfig(name: String, jobClass: Class[_], outputClasses: Option[Tuple2[Class[_],Class[_]]]) { | |
val conf = new Configuration() |
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
trait OutputConverter[K, V, S] { | |
def toKeyValue(s: S): (K, V) | |
} | |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
trait DataSink[K, V, B] { | |
def outputTypeName: String | |
def outputPath: Path | |
def outputFormat: Class[_ <: FileOutputFormat[K,V]] |