Your SlideShare is downloading. ×
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
riak-js: Javascript Turtles All the Way Down
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

riak-js: Javascript Turtles All the Way Down

8,058

Published on

riak-js is an awesome client driver for the Riak distributed datastore.

riak-js is an awesome client driver for the Riak distributed datastore.

Published in: Technology
0 Comments
15 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,058
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
15
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • Like all these turtles marching toward the sea, we’re on a path. And that path is the adoption of JavaScript in lots of places it hasn’t been before.\n
  • Like all these turtles marching toward the sea, we’re on a path. And that path is the adoption of JavaScript in lots of places it hasn’t been before.\n
  • Like all these turtles marching toward the sea, we’re on a path. And that path is the adoption of JavaScript in lots of places it hasn’t been before.\n
  • Like all these turtles marching toward the sea, we’re on a path. And that path is the adoption of JavaScript in lots of places it hasn’t been before.\n
  • So you’re probably saying “What about CouchDB? It has JavaScript”. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don’t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  • So you’re probably saying “What about CouchDB? It has JavaScript”. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don’t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  • So you’re probably saying “What about CouchDB? It has JavaScript”. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don’t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  • So you’re probably saying “What about CouchDB? It has JavaScript”. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don’t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  • * “Your data is safe with us.”\n* “Just add more machines.”\n* “Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.”\n
  • * “Your data is safe with us.”\n* “Just add more machines.”\n* “Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.”\n
  • * “Your data is safe with us.”\n* “Just add more machines.”\n* “Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.”\n
  • * “Your data is safe with us.”\n* “Just add more machines.”\n* “Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.”\n
  • * “Your data is safe with us.”\n* “Just add more machines.”\n* “Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.”\n
  • So if you want to work with Riak from node.js, Francisco Treacy <point him out> wrote this awesome driver called riak-js. It’s also got a beautiful website at riakjs.org that is envy of all READMEs.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Hosted on no.de\n
  • \n
  • \n
  • \n
  • Transcript

    • 1. riak-jsJavaScript turtles all the way down Sean Cribbs http://whenchemistsattack.com/2008/04/25/turtles-all-the-way-down/
    • 2. Browser Server DB
    • 3. Browser JavaScript Java, Ruby, Server PHP, Python DB SQL
    • 4. Browser JavaScript JavaScript Java, Ruby, Server node.js PHP, Python DB SQL SQL
    • 5. Browser JavaScript JavaScript JavaScript Java, Ruby, Server node.js node.js PHP, Python DB SQL SQL JavaScript?!
    • 6. Browser JavaScript JavaScript JavaScript Java, Ruby, Server node.js node.js PHP, Python DB SQL SQL JavaScript?! http://animals.nationalgeographic.com/animals/reptiles/kemps-ridley-sea-turtle/
    • 7. What about Couch? It has JavaScript.
    • 8. http://captainwildchild.blogspot.com/2011/04/stopping-for-turtles.htmlWhat about Couch? It has JavaScript.
    • 9. http://www.comicbookmovie.com/teenage_mutant_ninja_turtles/news/?a=18553What about Couch? It has JavaScript.
    • 10. What is Riak?
    • 11. What is Riak?• Distributed, Fault-Tolerant, Replicated
    • 12. What is Riak?• Distributed, Fault-Tolerant, Replicated• Scales out linearly
    • 13. What is Riak?• Distributed, Fault-Tolerant, Replicated• Scales out linearly• Flexible data model
    • 14. What is Riak?• Distributed, Fault-Tolerant, Replicated• Scales out linearly• Flexible data model
    • 15. What is Riak? PLUS IPT!• Distributed, JAVASCR Fault-Tolerant, Replicated• Scales out linearly• Flexible data model
    • 16. riakjs.org
    • 17. Getting Started
    • 18. Getting Started Install Riak or Riak Search:http://downloads.basho.com
    • 19. Getting Started Install Riak or Riak Search: http://downloads.basho.com$ npm install riak-js@latest
    • 20. Getting Started Install Riak or Riak Search: http://downloads.basho.com$ npm install riak-js@latest$ git clone git://github.com/frank06/riak-js
    • 21. Getting Started Install Riak or Riak Search: http://downloads.basho.com$ npm install riak-js@latest$ git clone git://github.com/frank06/riak-js
    • 22. Basic ClientOperations http://ijustwanttofitin.com/tag/rally-cars/
    • 23. Basic Operations
    • 24. Basic Operations// Get a client (pass options if needed)var db = require(riak-js).getClient()
    • 25. Basic Operations// Get a client (pass options if needed)var db = require(riak-js).getClient()// Fetch an objectdb.get(conferences, nodeconf,  function(err, data) {    console.log("Found the conference:" + sys.inspect(data))  })
    • 26. Basic Operations// Get a client (pass options if needed)var db = require(riak-js).getClient()// Fetch an object typical nodedb.get(conferences, nodeconf, callback style  function(err, data) {    console.log("Found the conference:" + sys.inspect(data))  })
    • 27. Basic Operations// Get a client (pass options if needed)var db = require(riak-js).getClient()// Fetch an object typical nodedb.get(conferences, nodeconf, callback style  function(err, data) {    console.log("Found the conference:" + sys.inspect(data))  })// Store an objectdb.save(conferences, nodeconf,        {date:"2011-05-05",         title: "nodeconf 2011",         presenters: ["Sean Cribbs"]})
    • 28. Basic Operations Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 29. Basic Operations// Delete an objectdb.remove(conferences, nodeconf) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 30. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 31. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master)db.keys(frameworks,{keys:stream}). on(keys, cb).start() Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 32. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master)db.keys(frameworks,{keys:stream}). on(keys, cb).start()// Give me them alldb.getAll(frameworks) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 33. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master)db.keys(frameworks,{keys:stream}). on(keys, cb).start()// Give me them alldb.getAll(frameworks) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 34. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master)db.keys(frameworks,{keys:stream}). on(keys, cb).start()// Give me them alldb.getAll(frameworks)// How many are there? (counts keys) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 35. Basic Operations// Delete an objectdb.remove(conferences, nodeconf)// Does this key exist?db.exists(frameworks, node.js)// Stream the keys (on master)db.keys(frameworks,{keys:stream}). on(keys, cb).start()// Give me them alldb.getAll(frameworks)// How many are there? (counts keys)db.count(frameworks) Picture: http://www.scooponpets.com/Turtlesaspets.html
    • 36. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) function cb(err, data, META){ } Picture: http://chronotron.files.wordpress.com/2010/07/turtles.png
    • 37. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb)
    • 38. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata
    • 39. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType
    • 40. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId
    • 41. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId • links, usermeta
    • 42. Meta Objectdb.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId • links, usermeta • quorums (r,w,dw), returnBody
    • 43. Meta Objectfunction cb(err, data, META){ }
    • 44. Meta Object function cb(err, data, META){ }• Response-time metadata
    • 45. Meta Object function cb(err, data, META){ }• Response-time metadata • bucket, key, vclock
    • 46. Meta Object function cb(err, data, META){ }• Response-time metadata • bucket, key, vclock • links, usermeta
    • 47. Meta Object function cb(err, data, META){ }• Response-time metadata • bucket, key, vclock • links, usermeta • lastMod, etag, statusCode
    • 48. Using Meta
    • 49. Using Meta// Add a link to the objectdb.get(frameworks, node.js,  function(err, data, meta){    meta.addLink({bucket:vm, key:v8, tag:vm});    db.save(frameworks, node.js, data, meta)  })
    • 50. Using Meta// Add a link to the objectdb.get(frameworks, node.js,  function(err, data, meta){    meta.addLink({bucket:vm, key:v8, tag:vm});    db.save(frameworks, node.js, data, meta)  })// Set the content typedb.save(pages, index.html,        <html><body>Hello, world!</body></html>,        {contentType: html})
    • 51. Querying Beyond Key-Value Picture: http://greencs.files.wordpress.com/2008/07/turtle- nom.jpg
    • 52. Link-walking Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
    • 53. Link-walking// Find friendsdb.walk(people, sean, [[_,friend]]) Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
    • 54. Link-walking// Find friendsdb.walk(people, sean, [[_,friend]])// Find acquaintances of friendsdb.walk(people, mathias,        [[_,friend], Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
    • 55. Link-walking// Find friendsdb.walk(people, sean, [[_,friend]])// Find acquaintances of friendsdb.walk(people, mathias,        [[_,friend],         [people,_]]) Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
    • 56. Wait. You said Riakhad JavaScript in it! U MAD? Picture: http://arsnotoria.blogspot.com/2010_04_18_archive.html
    • 57. MapReduce
    • 58. MapReduce list of keys
    • 59. MapReduce list of keysmap() map() map() map() map()
    • 60. MapReduce list of keysmap() map() map() map() map() reduce()
    • 61. MapReduce list of keysmap() map() map() map() map() reduce() results
    • 62. MapReduce list of keys JSONmap() map() map() map() map() reduce() results
    • 63. MapReduce list of keys JSON map() map() map() map() map()JavaScript JavaScript JavaScript JavaScript JavaScript reduce() results
    • 64. MapReduce list of keys JSON map() map() map() map() map()JavaScript JavaScript JavaScript JavaScript JavaScript reduce() JavaScript results
    • 65. MapReduce list of keys JSON map() map() map() map() map()JavaScript JavaScript JavaScript JavaScript JavaScript reduce() JavaScript results JSON
    • 66. MapReduce
    • 67. MapReduce// Execute a MapReduce querydb.add(frameworks) // Use all keys in bucket  .map(Riak.mapValuesJson) // Map using a built-in  .run(function(err, data){ // Execute the query         console.log(data);       })
    • 68. MapReduce// Execute a MapReduce querydb.add(frameworks) // Use all keys in bucket  .map(Riak.mapValuesJson) // Map using a built-in  .run(function(err, data){ // Execute the query         console.log(data);       })// Send a focused querydb.add(frameworks, node.js) // Start with one key  .link({ bucket: "vm"}) // Follow some links  .map(function(obj){ // Map using an inline         var data =            Riak.mapValuesJson(obj)[0];         return [data.name]       })  .reduce(Riak.reduceSort) // Sort via reduce  .run()
    • 69. MapReduce
    • 70. MapReduce// Initiate MapReduce with a key-filterdb.add({ bucket: emails,         key_filters: [["ends_with", "basho.com"]] }) // Map with a phase-argument  .map({ name:Riak.mapByFields,         arg: { joined:2010-01-01 })  .run()
    • 71. Riak Search
    • 72. Riak Search// Turn on automatic document indexingdb.enableIndex(documents)
    • 73. Riak Search// Turn on automatic document indexingdb.enableIndex(documents)// Perform a simple searchdb.search(documents, title:scalable)
    • 74. Riak Search// Turn on automatic document indexingdb.enableIndex(documents)// Perform a simple searchdb.search(documents, title:scalable)// Start a MapReduce query with searchdb.addSearch(documents, title:scalable)// From here, add map and reduce phases
    • 75. etc.
    • 76. etc.• Session Store
    • 77. etc.• Session Store• Mini-Riak Test Server
    • 78. etc.• Session Store• Mini-Riak Test Server• Multi-protocol (HTTP, Protobuffs)
    • 79. etc.• Session Store• Mini-Riak Test Server• Multi-protocol (HTTP, Protobuffs)• Luwak (large files)
    • 80. COME AT ME BRO Picture: http://fl.biology.usgs.gov/posters/Herpetology/Snapping_Turtles/snapping_turtles.html Demo Timehttps://github.com/basho/riaktant
    • 81. Questions?
    • 82. Questions? sean@basho.com @seancribbs jsconf.basho.com
    • 83. Riak on Turtles (someday)Picture: http://scienceblogs.com/bioephemera/2008/07/gpsequipped_box_turtle_leads_p.php

    ×