Advanced CouchDB Rotterdam.rb July 2010

  • 5,308 views
Uploaded on

CouchDB talk about it's potential, it's unique features, how map/reduce works (simplified) and just how awesome CouchDB really is. Rock on!

CouchDB talk about it's potential, it's unique features, how map/reduce works (simplified) and just how awesome CouchDB really is. Rock on!

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,308
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
133
Comments
0
Likes
10

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

Transcript

  • 1. CouchDB relax
  • 2. CouchDB relax Sander van de Graaf svdgraaf
  • 3. RELAX...
  • 4. PERFORM LIKE A PR0N STAR
  • 5. TOPICS • NoSQL • CouchDB in a nutshell • Querying • map/reduce • Fulltext search • CouchApps
  • 6. NOSQL
  • 7. IT’S A MOVEMENT
  • 8. 1998
  • 9. Carlo Strozzi
  • 10. NOSQL == Not Only SQL
  • 11. “[The NoSQL movement] departs from the relational model altogether, it should therefore have been called more appropriately ‘NoREL’, or something to that effect.” - Carlo Strozzi
  • 12. CouchDB relax
  • 13. NUTSHELL
  • 14. SPEED
  • 15. APPEND ONLY
  • 16. NO REPAIR NEEDED
  • 17. COMPACTING
  • 18. HTTP SERVER
  • 19. CAP
  • 20. CouchDB CAP
  • 21. CouchDB EVENTUALLY CONSISTENT
  • 22. FULL REST API
  • 23. REST • GET • SELECT • PUT • UPDATE • POST • INSERT • DELETE • DELETE • COPY • ...
  • 24. JSON { total_rows: 2, offset: 0, rows: [ { id: '_design/foobar', key: '_design/foobar', value: { rev: '5-982b2fc36835715b2aae54609b5d5f1e' } }, { id: 'f0e1fd96eb6e094f74dda8d949000a6a', key: 'f0e1fd96eb6e094f74dda8d949000a6a', value: { rev: '1-86bca407fce8234a63c90ff549b56b10' } }, ] }
  • 25. REPLICATION
  • 26. CouchDB relax
  • 27. CouchDB relax CouchDB relax
  • 28. CouchDB relax CouchDB relax CouchDB relax CouchDB relax
  • 29. CouchDB relax CouchDB relax
  • 30. CouchDB relax CouchDB relax CouchDB relax
  • 31. US NL CouchDB relax CouchDB relax CouchDB relax
  • 32. Laptop Desktop CouchDB relax CouchDB relax Phone CouchDB relax
  • 33. P2P WEB
  • 34. QUERYING
  • 35. SELECT * FROM documents WHERE id = 123 GET /documents/123
  • 36. SELECT * FROM documents WHERE id = 123 GET /documents/123 PUT /documents/123 POST /documents/123 DELETE /documents/123 etc.
  • 37. MAP/REDUCE
  • 38. INPUT IP Bytes 212.122.174.13 18271 212.122.174.13 191726 212.122.174.13 198 74.119.8.111 91272 74.119.8.111 8371 212.122.174.13 43
  • 39. MAPPER => REDUCER IP Bytes 18271 191726 212.122.174.13 198 43 91272 74.119.8.111 8371
  • 40. AFTER REDUCE IP Bytes 212.122.174.13 210238 74.119.8.111 99643
  • 41. MAP/REDUCE SELECT COUNT(foo) FROM documents WHERE 1 GROUP BY foo;
  • 42. MAP/REDUCE
  • 43. MAP/REDUCE function(doc) { emit(doc.foo, doc); }
  • 44. MAP/REDUCE
  • 45. MAP/REDUCE function(keys, values, rereduce) { return sum(values); }
  • 46. MAP/REDUCE
  • 47. COUCHDB-LUCENE http://github.com/rnewson/couchdb-lucene
  • 48. CONFIG [external] fti=/path/to/python /path/to/couchdb-lucene/tools/couchdb-external-hook.py [httpd_db_handlers] _fti = {couch_httpd_external, handle_external_req, <<"fti">>}
  • 49. http://127.0.0.1:5984> GET /foobar/_design/foobar
  • 50. _DESIGN { _id: '_design/foobar', _rev: '8-03a6bc983c721b1cc0ae4b461326bc31', language: 'javascript', views: { foo: { map: 'function(doc) {n emit(doc.foo,1);n}', reduce: 'function(keys, values, rereduce) {return sum(values);}' } } }
  • 51. _DESIGN { _id: '_design/foobar', _rev: '8-03a6bc983c721b1cc0ae4b461326bc31', language: 'javascript', views: { foo: { map: 'function(doc) {n emit(doc.foo,1);n}', reduce: 'function(keys, values, rereduce) {return sum(values);}' } }, fulltext: { by_subject: { index:"function(doc) { var ret=new Document(); ret.add (doc.subject); return ret }" }, } }
  • 52. _DESIGN function(doc) { var ret=new Document(); ret.add(doc.subject); return ret }
  • 53. _DESIGN function(doc) { var result = new Document(); result.add(doc.subject, {"field":"subject", "store":"yes"}); result.add(doc.content, {"field":"subject"}); result.add(new Date(), {"field":"indexed_at"}); return result; }
  • 54. http://127.0.0.1:5984> GET /foobar/_fti/_design/foo/by_subject?q=foobar
  • 55. http://127.0.0.1:5984> GET /foobar/_fti/_design/foo/by_subject?q=foobar
  • 56. COUCHAPPS http://github.com/couchapp/couchapp
  • 57. “Distributed, scalable, web applications you say? omgwtfbbq!?!1!!!11!1!eleven”
  • 58. _attachments
  • 59. CouchDB relax CouchDB relax CouchDB relax
  • 60. COUCHAPP PUSH HTTP://LOCALHOST:5984/MYDB
  • 61. LISTS http://127.0.0.1:5984> GET /relax/_design/relax/_list/posts/all/foobar HTTP/1.1 200 OK Vary: Accept Transfer-Encoding: chunked Server: CouchDB/0.11.0 (Erlang OTP/R13B) Etag: "DZZ19EPLWLHI89K1FOW9DGFT5" Date: Sun, 11 Jul 2010 09:55:42 GMT Content-Type: text/html <h1>ponies</h1><p>rock!</p>
  • 62. CouchDB relax
  • 63. CouchDB relax
  • 64. COUCHDBX http://janl.github.com/couchdbx/
  • 65. Q?