SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
rogue:
a scala dsl for mongodb
CS442 - 5/24/2011
Jorge Ortiz (@jorgeortiz85)
what is foursquare?
location-based social network - “check-in” to bars,
restaurants, museums, parks, etc
  friend-finder (where are my friends right now?)
  virtual game (badges, points, mayorships)
  city guide (local, personalized recommendations)
  location diary + stats engine (where was I a year ago?)
  specials (get rewards at your favorite restaurant)
foursquare: the numbers

>9M users
~3M checkins/day
>15M venues
>300k merchants
>60 employees
foursquare: the tech

 Nginx, HAProxy
 Scala, Lift
 MongoDB, PostgreSQL (legacy)
 (Kestrel, Munin, Ganglia, Python, Memcache, ...)
 All on EC2
what is mongodb?

fast, schema-less document store
indexes & rich queries on any attribute
sharding, auto-balancing
replication
geo-indexes
mongodb: our numbers

8 clusters
  some sharded, some not
  some master/slave, some replica set
~40 machines (68.4GB, m2.4xl on EC2)
2.3 billion records
~15k QPS
mongodb: bson
json++
binary wire format
more built-in types:
  objectid
  date
  regex
  bina
mongodb: bson example

{
    “_id” :
      { “oid” : “4ddbd194686148110d5c1ccc” },
    “venuename” : “Starbucks”,
    “mayorid” : 464,
    “tags” : [“coffee”, “wifi”, “snacks”],
    “latlng” : [39.0, -74.0]
}
mongodb: query example
{
    “mayorid” : { “$lte” : 100 },
    “venuename” : { “$eq” : “Starbucks” },
    “tags” : { “$contains” : “wifi” },
    “latlng” : { “$near” : [39.0, -74.0] }
}

{ “_id” : -1 }
mongodb: query example
val query =
  (BasicDBOBjectBuilder
    .start
    .push(“mayorid”)
      .add(“$lte”, 100)
    .pop
    .push(“veneuname”)
      .add(“$eq”, “Starbucks”)
    .pop
    .get)
rogue: a scala dsl for mongo

 type-safe
 all mongo query features
 logging & validation hooks
 pagination
 index-aware
 cursors
           http://github.com/foursquare/rogue
rogue: schema example

class Venue extends MongoRecord[Venue] {
  object _id extends ObjectIdField(this)
  object venuename extends StringField(this)
  object mayorid extends LongField(this)
  object tags extends ListField[String](this)
  object latlng extends LatLngField(this)
}
rogue: code example

val vs: List[Venue] =
  (Venue where (_.mayorid <= 100)
          and (_.venuename eqs “Starbucks”)
          and (_.tags contains “wifi”)
          and (_.latlng near
                (39.0, -74.0, Degrees(0.2))
    orderDesc (_._id)
        fetch (5))
rogue: BaseQuery

class BaseQuery[M <: MongoRecord[M],
                R, Ord, Sel, Lim, Sk](...) {

    def where[F](clause: M => QueryClause[F]): ...

    ...
}
rogue: QueryField

class QueryField[V, M <: MongoRecord[M]]
                (val field: Field[V, M]) {
  def eqs(v: V) = new EqClause(...)
  def neqs(v: V) = ...
  def in[L <% List[V]](vs: L) = ...
  def nin[L <% List[V]](vs: L) = ...
  def exists(b: Boolean) = ...
}
rogue: implicits

Field[F, M] => QueryField[F, M]
Field[LatLong, M] => GeoQueryField[M]
Field[List[F], M] => ListQueryField[F, M]
Field[String, M] => StringQueryField[M]
Field[Int, M] => NumericQueryField[Int, M]
Field[Double, M] => NumericQueryField[Double, M]
...
rogue: select


val vs: List[(Long, Int)] =
  (Venue where (_.venuename eqs “Starbucks”)
        select (_.mayorid, _.mayorCheckins)
         fetch ())
rogue: select
class BaseQuery[M <: MongoRecord[M],
                R, Ord, Sel, Lim, Sk](...) {

    def select[F1, F2](
      f1: M => SelectField[F1, M],
      f2: M => SelectField[F2, M]):
        BaseQuery[M, (F1, F2), ...] = ...

    ...
}
rogue: select problems


val vs: List[???] =
  (Venue where (_.venuename eqs “Starbucks”)
        select (_.mayorid, _.mayorCheckins)
        select (_.venuename)
         fetch ())
rogue: order problems


val vs: List[Venue] =
  (Venue where (_.venuename eqs “Starbucks”)
     orderDesc (_._id)
      orderAsc (_.mayorid)   // (???)
         fetch ())
rogue: limit problems


val vs: List[Venue] =
  (Venue where (_.venuename eqs “Starbucks”)
         limit (5)
         limit (100)   // (???)
         fetch ())
rogue: phantom types


Sel =:= Selected, Unselected
Ord =:= Ordered, Unordered
Lim =:= Limited, Unlimited
Sk =:= Skipped, Unskipped
rogue: select phantom
class BaseQuery[M <: MongoRecord[M],
                R, Sel, Ord, Lim, Sk](...) {

    def select[F1, F2](
      f1: M => SelectField[F1, M],
      f2: M => SelectField[F2, M])
     (implicit ev: Sel =:= Unselected):
        BaseQuery[M, (F1, F2), Selected, ...] = ...

    ...
}
rogue: select problems

val vs: List[???] =
  (Venue where (_.venuename eqs “Starbucks”)
        select (_.mayorid, _.mayorCheckins)
        select (_.venuename)
         fetch ())

// won’t compile!
rogue: logging & validation

 logging:
   slf4j
   Tracer
 validation:
   radius, $in size
   index checks
rogue: pagination

val query: Query[Venue] = ...

val vs: List[Venue] =
  (query
    .countPerPage(20)
    .setPage(5)
    .fetch())
rogue: cursors


val query: Query[Checkin] = ...

for (checkin <- query) {
  ... f(checkin) ...
}
rogue: index-aware


val vs: List[Checkin] =
  (Checkin
    where (_.userid eqs 646)
      and (_.venueid eqs vid)
    fetch ())
rogue: index-aware


val vs: List[Checkin] =
  (Checkin
    where (_.userid eqs 646)
      and (_.venueid eqs vid) // hidden scan!
    fetch ())
rogue: index-aware


val vs: List[Checkin] =
  (Checkin
    where (_.userid eqs 646) // known index
     scan (_.venueid eqs vid) // known scan
    fetch ())
rogue: future directions


 iteratees for cursors
 compile-time index checking
 select partial objects
 generate full javascript for mapreduce
we’re hiring
    (nyc & sf)
http://foursquare.com/jobs
  jorge@foursquare.com
        @jorgeortiz85

Weitere ähnliche Inhalte

Was ist angesagt?

Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitivesalexisabril
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84Mahmoud Samir Fayed
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
PHP 7 – What changed internally?
PHP 7 – What changed internally?PHP 7 – What changed internally?
PHP 7 – What changed internally?Nikita Popov
 
PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)Nikita Popov
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwoEishay Smith
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHPTaras Kalapun
 
Random. Kinda.
Random. Kinda.Random. Kinda.
Random. Kinda.awwaiid
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기Suyeol Jeon
 
Using spark data frame for sql
Using spark data frame for sqlUsing spark data frame for sql
Using spark data frame for sqlDaeMyung Kang
 

Was ist angesagt? (20)

Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitives
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
P5
P5P5
P5
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
PHP 7 – What changed internally?
PHP 7 – What changed internally?PHP 7 – What changed internally?
PHP 7 – What changed internally?
 
PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwo
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
Random. Kinda.
Random. Kinda.Random. Kinda.
Random. Kinda.
 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기
 
Using spark data frame for sql
Using spark data frame for sqlUsing spark data frame for sql
Using spark data frame for sql
 

Ähnlich wie CS442 - Rogue: A Scala DSL for MongoDB

MongoSF - mongodb @ foursquare
MongoSF - mongodb @ foursquareMongoSF - mongodb @ foursquare
MongoSF - mongodb @ foursquarejorgeortiz85
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik ErlandsonDatabricks
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)MongoSF
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDBTakahiro Inoue
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceLivePerson
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme SwiftMovel
 
Functional and reactive u is gwt.create 2015
Functional and reactive u is gwt.create 2015Functional and reactive u is gwt.create 2015
Functional and reactive u is gwt.create 2015hezamu
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersKazuhiro Sera
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184Mahmoud Samir Fayed
 
Scala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldScala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldWerner Hofstra
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Codestasimus
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Anton Arhipov
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiInfluxData
 

Ähnlich wie CS442 - Rogue: A Scala DSL for MongoDB (20)

MongoSF - mongodb @ foursquare
MongoSF - mongodb @ foursquareMongoSF - mongodb @ foursquare
MongoSF - mongodb @ foursquare
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduce
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme Swift
 
Functional and reactive u is gwt.create 2015
Functional and reactive u is gwt.create 2015Functional and reactive u is gwt.create 2015
Functional and reactive u is gwt.create 2015
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for Beginners
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184
 
Scala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldScala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereld
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
 

CS442 - Rogue: A Scala DSL for MongoDB

  • 1. rogue: a scala dsl for mongodb CS442 - 5/24/2011 Jorge Ortiz (@jorgeortiz85)
  • 2. what is foursquare? location-based social network - “check-in” to bars, restaurants, museums, parks, etc friend-finder (where are my friends right now?) virtual game (badges, points, mayorships) city guide (local, personalized recommendations) location diary + stats engine (where was I a year ago?) specials (get rewards at your favorite restaurant)
  • 3. foursquare: the numbers >9M users ~3M checkins/day >15M venues >300k merchants >60 employees
  • 4. foursquare: the tech Nginx, HAProxy Scala, Lift MongoDB, PostgreSQL (legacy) (Kestrel, Munin, Ganglia, Python, Memcache, ...) All on EC2
  • 5. what is mongodb? fast, schema-less document store indexes & rich queries on any attribute sharding, auto-balancing replication geo-indexes
  • 6. mongodb: our numbers 8 clusters some sharded, some not some master/slave, some replica set ~40 machines (68.4GB, m2.4xl on EC2) 2.3 billion records ~15k QPS
  • 7. mongodb: bson json++ binary wire format more built-in types: objectid date regex bina
  • 8. mongodb: bson example { “_id” : { “oid” : “4ddbd194686148110d5c1ccc” }, “venuename” : “Starbucks”, “mayorid” : 464, “tags” : [“coffee”, “wifi”, “snacks”], “latlng” : [39.0, -74.0] }
  • 9. mongodb: query example { “mayorid” : { “$lte” : 100 }, “venuename” : { “$eq” : “Starbucks” }, “tags” : { “$contains” : “wifi” }, “latlng” : { “$near” : [39.0, -74.0] } } { “_id” : -1 }
  • 10. mongodb: query example val query = (BasicDBOBjectBuilder .start .push(“mayorid”) .add(“$lte”, 100) .pop .push(“veneuname”) .add(“$eq”, “Starbucks”) .pop .get)
  • 11. rogue: a scala dsl for mongo type-safe all mongo query features logging & validation hooks pagination index-aware cursors http://github.com/foursquare/rogue
  • 12. rogue: schema example class Venue extends MongoRecord[Venue] { object _id extends ObjectIdField(this) object venuename extends StringField(this) object mayorid extends LongField(this) object tags extends ListField[String](this) object latlng extends LatLngField(this) }
  • 13. rogue: code example val vs: List[Venue] = (Venue where (_.mayorid <= 100) and (_.venuename eqs “Starbucks”) and (_.tags contains “wifi”) and (_.latlng near (39.0, -74.0, Degrees(0.2)) orderDesc (_._id) fetch (5))
  • 14. rogue: BaseQuery class BaseQuery[M <: MongoRecord[M], R, Ord, Sel, Lim, Sk](...) { def where[F](clause: M => QueryClause[F]): ... ... }
  • 15. rogue: QueryField class QueryField[V, M <: MongoRecord[M]] (val field: Field[V, M]) { def eqs(v: V) = new EqClause(...) def neqs(v: V) = ... def in[L <% List[V]](vs: L) = ... def nin[L <% List[V]](vs: L) = ... def exists(b: Boolean) = ... }
  • 16. rogue: implicits Field[F, M] => QueryField[F, M] Field[LatLong, M] => GeoQueryField[M] Field[List[F], M] => ListQueryField[F, M] Field[String, M] => StringQueryField[M] Field[Int, M] => NumericQueryField[Int, M] Field[Double, M] => NumericQueryField[Double, M] ...
  • 17. rogue: select val vs: List[(Long, Int)] = (Venue where (_.venuename eqs “Starbucks”) select (_.mayorid, _.mayorCheckins) fetch ())
  • 18. rogue: select class BaseQuery[M <: MongoRecord[M], R, Ord, Sel, Lim, Sk](...) { def select[F1, F2]( f1: M => SelectField[F1, M], f2: M => SelectField[F2, M]): BaseQuery[M, (F1, F2), ...] = ... ... }
  • 19. rogue: select problems val vs: List[???] = (Venue where (_.venuename eqs “Starbucks”) select (_.mayorid, _.mayorCheckins) select (_.venuename) fetch ())
  • 20. rogue: order problems val vs: List[Venue] = (Venue where (_.venuename eqs “Starbucks”) orderDesc (_._id) orderAsc (_.mayorid) // (???) fetch ())
  • 21. rogue: limit problems val vs: List[Venue] = (Venue where (_.venuename eqs “Starbucks”) limit (5) limit (100) // (???) fetch ())
  • 22. rogue: phantom types Sel =:= Selected, Unselected Ord =:= Ordered, Unordered Lim =:= Limited, Unlimited Sk =:= Skipped, Unskipped
  • 23. rogue: select phantom class BaseQuery[M <: MongoRecord[M], R, Sel, Ord, Lim, Sk](...) { def select[F1, F2]( f1: M => SelectField[F1, M], f2: M => SelectField[F2, M]) (implicit ev: Sel =:= Unselected): BaseQuery[M, (F1, F2), Selected, ...] = ... ... }
  • 24. rogue: select problems val vs: List[???] = (Venue where (_.venuename eqs “Starbucks”) select (_.mayorid, _.mayorCheckins) select (_.venuename) fetch ()) // won’t compile!
  • 25. rogue: logging & validation logging: slf4j Tracer validation: radius, $in size index checks
  • 26. rogue: pagination val query: Query[Venue] = ... val vs: List[Venue] = (query .countPerPage(20) .setPage(5) .fetch())
  • 27. rogue: cursors val query: Query[Checkin] = ... for (checkin <- query) { ... f(checkin) ... }
  • 28. rogue: index-aware val vs: List[Checkin] = (Checkin where (_.userid eqs 646) and (_.venueid eqs vid) fetch ())
  • 29. rogue: index-aware val vs: List[Checkin] = (Checkin where (_.userid eqs 646) and (_.venueid eqs vid) // hidden scan! fetch ())
  • 30. rogue: index-aware val vs: List[Checkin] = (Checkin where (_.userid eqs 646) // known index scan (_.venueid eqs vid) // known scan fetch ())
  • 31. rogue: future directions iteratees for cursors compile-time index checking select partial objects generate full javascript for mapreduce
  • 32. we’re hiring (nyc & sf) http://foursquare.com/jobs jorge@foursquare.com @jorgeortiz85

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n