Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
rogue:a scala dsl for mongodbScalaDays 2011 - 6/2/2011Jason Liszka (@jliszka)Jorge Ortiz (@jorgeortiz85)
what is foursquare?location-based social network - “check-in” to bars,restaurants, museums, parks, etc  friend-finder (whe...
foursquare: the numbers>9M users~3M checkins/day>15M venues>400k merchants>60 employees
foursquare: the tech Nginx, HAProxy Scala, Lift MongoDB, PostgreSQL (legacy) (Kestrel, Munin, Ganglia, Python, Memcache, ....
what is mongodb?fast, schema-less document storeindexes & rich queries on any fieldsharding, auto-balancingreplicationgeo-...
mongodb: our numbers8 clusters  some sharded, some not  some master/slave, some replica set~40 machines (68.4GB, m2.4xl on...
mongodb: bsonjson++binary wire formatmore built-in types:  objectid  date  regex  bina
mongodb: bson example{    “_id” :      { “oid” : “4ddbd194686148110d5c1ccc” },    “venuename” : “Starbucks”,    “mayorid” ...
mongodb: query example{    “mayorid” : { “$lte” : 100 },    “venuename” : “Starbucks”,    “tags” : “wifi”,    “latlng” : {...
mongodb: query exampleval query =  (BasicDBOBjectBuilder    .start    .push(“mayorid”)      .add(“$lte”, 100)    .pop    ....
rogue: a scala dsl for mongo type-safe all mongo query features logging & validation hooks pagination index-aware cursors ...
rogue: schema exampleclass Venue extends MongoRecord[Venue] {  object _id extends ObjectIdField(this)  object venuename ex...
rogue: code exampleval vs: List[Venue] =  (Venue where (_.mayorid <= 100)          and (_.venuename eqs “Starbucks”)      ...
rogue: BaseQueryclass BaseQuery[M <: MongoRecord[M], R,                Ord, Sel, Lim, Sk](...) {    def where[F](clause: M...
rogue: QueryFieldclass QueryField[V, M <: MongoRecord[M]]                (val field: Field[V, M]) {  def eqs(v: V) = new E...
rogue: implicitsField[F, M] => QueryField[F, M]Field[LatLong, M] => GeoQueryField[M]Field[List[F], M] => ListQueryField[F,...
rogue: selectval vs: List[(Long, Int)] =  (Venue where (_.venuename eqs “Starbucks”)        select (_.mayorid, _.mayorChec...
rogue: selectclass BaseQuery[M <: MongoRecord[M], R,                Ord, Sel, Lim, Sk](...) {    def select[F1, F2](      ...
rogue: select problemsval vs: List[???] =  (Venue where (_.venuename eqs “Starbucks”)        select (_.mayorid, _.mayorChe...
rogue: limit problemsval vs: List[Venue] =  (Venue where (_.venuename eqs “Starbucks”)         limit (5)         limit (10...
rogue: more limit problems(Venue where (_.venuename eqs “Starbucks”)       orderAsc (_.total_checkins)       limit (5)    ...
rogue: phantom types     Sel =:= Selected, Unselected     Ord =:= Ordered, Unordered     Lim =:= Limited, Unlimited     Sk...
rogue: phantom typesabstract   sealed   class   Orderedabstract   sealed   class   Unorderedabstract   sealed   class   Se...
rogue: initializing phantomsclass BaseQuery[M <: MongoRecord[M], R,                Ord, Sel, Lim, Sk](...) {  ...}def dflt...
rogue: select phantomclass BaseQuery[M <: MongoRecord[M], R,                Ord, Sel, Lim, Sk](...) {    def select[F1, F2...
rogue: =:=sealed abstract class =:=[From, To] ...implicit def tpEquals[A]: A =:= A = ...
rogue: select solutionsval vs: List[???] =  (Venue where (_.venuename eqs “Starbucks”)        select (_.mayorid, _.mayorCh...
rogue: limit solutions(Venue where (_.venuename eqs “Starbucks”)       orderAsc (_.total_checkins)       limit (5)       b...
rogue: index-awareval vs: List[Checkin] =  (Checkin    where (_.userid eqs 646)      and (_.venueid eqs vid)    fetch ())
rogue: index-awareval vs: List[Checkin] =  (Checkin    where (_.userid eqs 646)      and (_.venueid eqs vid) // hidden sca...
rogue: index-awareval vs: List[Checkin] =  (Checkin    where (_.userid eqs 646) // known index     scan (_.venueid eqs vid...
rogue: logging & validation logging:   slf4j   Tracer validation:   radius, $in size   index checks
rogue: paginationval query: Query[Venue] = ...val vs: List[Venue] =  (query    .countPerPage(20)    .setPage(5)    .fetch())
rogue: cursorsval query: Query[Checkin] = ...for (checkin <- query) {  ... f(checkin) ...}
rogue: future directions iteratees for cursors compile-time index checking select partial objects generate full javascript...
we’re hiring    (nyc & sf)http://foursquare.com/jobs  @jliszka, @jorgeortiz85
Prochain SlideShare
Chargement dans…5
×
16 447 vues

Publié le

mongodb: bson example{ “_id” : { “oid” : “4ddbd194686148110d5c1ccc” }, “venuename” : “Starbucks”, “mayorid” : 464, “tags” : [“coffee”, “wifi”, “snacks”], “latlng” : [39.0, -74.0]}

×