2015-10-21
- jennifer
- martym
import com.twitter.util.{Future => TwFuture} | |
import scala.concurrent.{Future => ScFuture, promise => ScPromise} | |
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = { | |
val prom = ScPromise[T] | |
twFuture.onSuccess { res: T => | |
prom.success(res) | |
} | |
twFuture.onFailure { t: Throwable => | |
prom.failure(t) | |
} |
2014-03-04 | 15dfb8e6cc4111e3a5bb600308919594 | 11 | |
---|---|---|---|
2014-03-06 | 81da510acc4111e387f3600308919594 | 61 |
// load error messages from a log into memory | |
// then interactively search for various patterns | |
// base RDD | |
val lines = sc.textFile("log.txt") | |
// transformed RDDs | |
val errors = lines.filter(_.startsWith("ERROR")) | |
val messages = errors.map(_.split("\t")).map(r => r(1)) | |
messages.cache() |
$ ./bin/spark-shell | |
14/04/18 15:23:49 INFO spark.HttpServer: Starting HTTP Server | |
14/04/18 15:23:49 INFO server.Server: jetty-7.x.y-SNAPSHOT | |
14/04/18 15:23:49 INFO server.AbstractConnector: Started [email protected]:49861 | |
Welcome to | |
____ __ | |
/ __/__ ___ _____/ /__ | |
_\ \/ _ \/ _ `/ __/ '_/ | |
/___/ .__/\_,_/_/ /_/\_\ version 0.9.1 | |
/_/ |