Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Revolute (Lightning Talk @ Big Data Scala meetup)

boia01
June 12, 2012

Revolute (Lightning Talk @ Big Data Scala meetup)

Project Revolute (Lightning Talk @ Big Data Scala meetup)

boia01

June 12, 2012
Tweet

More Decks by boia01

Other Decks in Programming

Transcript

  1. object Persons extends Table[(String, Int, String)] { def name =

    column[String]("name") def age = column[Int]("age") def gender = column[String]("gender") def * = name ~ age ~ gender }
  2. -- SQL select p.* from Persons ↓ /* Revolute */

    for { p Persons } yield p.* ←
  3. /* filtering */ for { p Persons if (p.age >

    21) ← } yield p.name ~ p.age
  4. /* combinators for complex expressions */ for { p Persons

    ← if (p.age > 21) && (gender === “m”) } yield p.name ~ p.age
  5. /* How much time are people spending per location? */

    for { Join(p, l) (Persons innerJoin Locations) ← on (_.name is _.name) _ Query.groupBy (p.name ~ l.city) ← time TimeSpent(l.timestamp) ← } yield p.name ~ l.city ~ time
  6. // context provides table bindings for taps/sinks // // e.g.

    Traffic table HDFS or S3 → // Parter table MySQL → // Summary table Google Spreadsheet → flow(context) { val myQuery = for { … } yield … insert { for { (partner, segment, views) <- myQuery if segment in Set("a", "b", "c") } yield partner ~ views } into Summary }
  7. * Query - one or more table joined together (“join”)

    - field selection and function application (“select”) - one or more filters (“where”) - grouping and sorting (“group by”, “sort by”) - aggregation based on groupings (“count()”, …) * Nest & chain queries * 1-1, 1-0/1, 1-N mappings * Null, Option & PartialFunction filtering … and (eventually) more awesome.