Created
August 21, 2013 19:08
-
-
Save emaxerrno/6298818 to your computer and use it in GitHub Desktop.
no vars
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 tupleListForPageView(pvld: PageViewLogData): TupleList = { | |
| import com.yieldmo.hadoop.scalding.DiscreteVariableStates._ | |
| val network = if ((Option(pvld.getCellular()) getOrElse false).asInstanceOf[Boolean]) "cell" else "wifi" | |
| val location = Option(pvld.getLocation()) getOrElse { new Location } | |
| val (metro: String, country: String) = { | |
| Option(location) map { loc: Location => | |
| val x1 = if (loc.getMetroCode != 0) "" + loc.getMetroCode else "other" | |
| val x2 = Option(loc.getCountryCode) map { x: String => getCountry(x) } | |
| (x1,x2) | |
| } getOrElse {("other", "other")} | |
| } | |
| def tupleListForResult(list: Iterable[ResultImpression]): TupleList = list.toList flatMap { result => | |
| def creativeListToLabelList(creativeList: Iterable[ResultCreative]): TupleList = creativeList.toList flatMap { creativeHead => | |
| def randomVariableAssignment(label:String, assign: String):(Long,Long,String,String) = | |
| (result.getPlacementId().toLong,creativeHead.getAdvertiserId.getValue,label,assign) | |
| List(randomVariableAssignment("metro", metro), | |
| randomVariableAssignment("network", network), | |
| randomVariableAssignment("country", country)) | |
| } | |
| creativeListToLabelList(scala.collection.JavaConversions.collectionAsScalaIterable(result.getCreatives())) | |
| } | |
| tupleListForResult(scala.collection.JavaConversions.collectionAsScalaIterable(pvld.getResults())) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment