Created
August 21, 2013 18:38
-
-
Save emaxerrno/6298433 to your computer and use it in GitHub Desktop.
tooNested.scala
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 isCell = (Option(pvld.getCellular()) getOrElse false).asInstanceOf[Boolean] | |
| val location = Option(pvld.getLocation()) getOrElse { new Location } | |
| var metro = "other" | |
| var country = "other" | |
| Option(location).foreach { loc: Location => | |
| if (loc.getMetroCode != 0) metro = "" + loc.getMetroCode | |
| Option(loc.getCountryCode) foreach { x: String => country = getCountry(x) } | |
| } | |
| def tupleListForResult(list: Iterable[ResultImpression]): TupleList = list match { | |
| case head :: tail => | |
| def t(advertiserId: Long, label: String, labelAssignment: String):(Long,Long,String,String) = | |
| (head.getPlacementId().toLong,advertiserId, label, labelAssignment) | |
| def creativeListToLabelList(creativeList: Iterable[ResultCreative]): TupleList = creativeList match{ | |
| case creativeHead::creativeTail => | |
| def tt(l:String, assign: String):(Long,Long,String,String) = t(creativeHead.getAdvertiserId.getValue,l,assign) | |
| List(tt("metro", metro), tt("country", country)) ++ creativeListToLabelList(creativeTail) | |
| case Nil => List() | |
| } | |
| creativeListToLabelList(scala.collection.JavaConversions.asScalaIterable(head.getCreatives())) | |
| case Nil => List() | |
| } | |
| tupleListForResult(scala.collection.JavaConversions.asScalaIterable(pvld.getResults())) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment