Couchdb

3,312 views
3,171 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,312
On SlideShare
0
From Embeds
0
Number of Embeds
575
Actions
Shares
0
Downloads
23
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Couchdb

  1. 1. CouchDB relax Kota Sakoda 2009 6 1
  2. 2. • cohtan ( Kota Sakoda ) • • • • • codecheck.in 2009 6 1
  3. 3. Agenda • DB CouchDB • 2009 6 1
  4. 4. What’s CouchDB? • Erlang DB • Not Relational! • RESTful API • SQL MapReduce • N-Master Replication 2009 6 1
  5. 5. Erlang 2009 6 1
  6. 6. Erlang • • • 0.9.0 11067 ! ($ cat src/couchdb/*.erl | wc) 2009 6 1
  7. 7. Document Oriented 2009 6 1
  8. 8. Document Oriented • RDB •1 JSON • JSON • 2009 6 1
  9. 9. { “_id”: “ABCDEFG”, “_rev”: “1-AB123C”, “type”: “person”, “name”: “Kota Sakoda”, “age”: 29, “computer”: [”MacBook Air”, “MacBook”, “Inspiron Mini 12”], } 2009 6 1
  10. 10. { “_id”: “ABCDEFG”, “_rev”: “2-AB123C”, “type”: “person”, “name”: “Kota Sakoda”, “age”: 29, “computer”: [”MacBook Air”, “MacBook”, “Inspiron Mini 12”, “SC430”], “hobby”:{“program”:[”perl”,”erlang”]} } 2009 6 1
  11. 11. RESTful API 2009 6 1
  12. 12. RESTful API • Crete HTTP PUT /dbname/docid • Read HTTP GET /dbname/docid • Update HTTP PUT /dbname/docid • Delete HTTP DELETE /dbname/docid 2009 6 1
  13. 13. RESTful API • http://wiki.apache.org/couchdb/Basics • Amazon EC2, ExtJS, C, C#, Erlang, Futon, Haskell, Java, JavaScript, LISP, LotusScript, Objective-C, Perl, PHP, Python, Ruby, Smalltalk 2009 6 1
  14. 14. MapReduce Framework 2009 6 1
  15. 15. MapReduce Framework • JavaScript MapReduce! • Map JSON KeyValue • Reduce KeyValue 2009 6 1
  16. 16. { “_id”:“ABCDEFG”, “_rev”:“1-A1B2C3”, “tag”:“perl couchdb cpan”, “title”:”AnyEvent::CouchDB”, “href”:”http://search.cpan.org/ ~beppu/AnyEvent-CouchDB/” } 2009 6 1
  17. 17. // Map Function function(doc) { if(doc.tag.match(/couchdb/i){ emit(doc.title, doc.href); } } 2009 6 1
  18. 18. Result 2009 6 1
  19. 19. // Map Function function(doc) { var tags = doc.tag.split(“ “); for(var i in tags) { emit(tags[i], 1); } } // Reduce Function function(keys, values) { return sum(values); } 2009 6 1
  20. 20. Result 2009 6 1
  21. 21. N-Master Replication 2009 6 1
  22. 22. $ curl -X POST --data '{”source”:”http://remote:5984/ somedb”,”target”:”somedb”}' http://localhost:5984/_replicate 2009 6 1
  23. 23. Replication Complete 2009 6 1
  24. 24. !!! 2009 6 1
  25. 25. 2009 6 1
  26. 26. N-Master Replication • Master - Slave • • source, target • ※ 2009 6 1
  27. 27. Demo 2009 6 1
  28. 28. Demo • cohtan Delicious CouchDB • All Document, Design Document, Temporary View, created view 2009 6 1
  29. 29. CouchApp 2009 6 1
  30. 30. CouchApp • CouchDB Design Document / Python Framework • Python • HTML JavaScript 2009 6 1
  31. 31. Sofa 2009 6 1
  32. 32. Sofa • CouchApp • CouchDB 2009 6 1
  33. 33. Demo 2009 6 1
  34. 34. Demo • Sofa Demo 2009 6 1
  35. 35. • Web Application Fit • RESTful JSON • • • Scaffold 2009 6 1
  36. 36. : http://delicious/com/cohtan/couchdb 2009 6 1

×