SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
couchdb, ruby,
and you.


   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber



   will leinweber — bitfission.com — merge.fm — @leinweber
couchdb



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
documents



   will leinweber — bitfission.com — merge.fm — @leinweber
json



       will leinweber — bitfission.com — merge.fm — @leinweber
rich documents



   will leinweber — bitfission.com — merge.fm — @leinweber
{
    "_id": "will",
    "_rev": "3-4352629382",
    "fullname": "Will Leinweber",
    "email": "will@bitfission.com",
    "sites": [
      {"blog": "bitfission.com", "hits": 42},
      {"github": "github.com/will"},
      {"twitter": "twitter.com/leinweber"},
      {"company": "merge.fm"}
    ]
}




         will leinweber — bitfission.com — merge.fm — @leinweber
schemaless



   will leinweber — bitfission.com — merge.fm — @leinweber
http api



   will leinweber — bitfission.com — merge.fm — @leinweber
restful



    will leinweber — bitfission.com — merge.fm — @leinweber
~% curl localhost:5984/appdb/docid
{"_id":"docid","_rev":"2-3779119708","look":"at all
this data","its_awesome":true}




             will leinweber — bitfission.com — merge.fm — @leinweber
~% curl localhost:5984/appdb/docid -i
HTTP/1.1 200 OK
Server: CouchDB/0.11.0 (Erlang OTP/R13B)
Etag: "2-3779119708"
Date: Wed, 28 Apr 2010 06:46:42 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 83
Cache-Control: must-revalidate




        will leinweber — bitfission.com — merge.fm — @leinweber
caching



   will leinweber — bitfission.com — merge.fm — @leinweber
clustering



    will leinweber — bitfission.com — merge.fm — @leinweber
replication



   will leinweber — bitfission.com — merge.fm — @leinweber
couchapps!



   will leinweber — bitfission.com — merge.fm — @leinweber
views



   will leinweber — bitfission.com — merge.fm — @leinweber
javascript
map/reduce


   will leinweber — bitfission.com — merge.fm — @leinweber
map


  will leinweber — bitfission.com — merge.fm — @leinweber
bit.ly/jscouchdb
example


   will leinweber — bitfission.com — merge.fm — @leinweber
{"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon",
    "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]}
{"_id":2,"name":"trees.jpg","user":"john","camera":"canon",
    "info":{"width":30,"height":250,"size":32091},"tags":["oak"]}
{"_id":3,"name":"snow.png","user":"john","camera":"canon",
    "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]}
{"_id":4,"name":"hawaii.png","user":"john","camera":"nikon",
    "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]}
{"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon",
    "info":{"width":320,"height":128,"size":49287},"tags":["maui"]}
{"_id":6,"name":"island.gif","user":"zztop","camera":"nikon",
    "info":{"width":640,"height":480,"size":50398},"tags":["maui"]}




                  will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.user, null);
}

       {
           "total_rows": 6,
           "rows": [
               {"id":"1","key":"bob","value":null},
               {"id":"5","key":"bob","value":null},
               {"id":"2","key":"john","value":null},
               {"id":"3","key":"john","value":null},
               {"id":"4","key":"john","value":null},
               {"id":"6","key":"zztop","value":null}
            ]
       }




                will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.name.match(/w+.(w{3})/)[1], null);
}



         {
             "total_rows": 6,
             "rows": [
                 {"id":"5","key":"gif","value":null},
                 {"id":"6","key":"gif","value":null},
                 {"id":"1","key":"jpg","value":null},
                 {"id":"2","key":"jpg","value":null},
                 {"id":"3","key":"png","value":null},
                 {"id":"4","key":"png","value":null}
              ]
         }




               will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.name.match(/w+.(w{3})/)[1], null);
}


  ?key="jpg"

         {
             "total_rows": 2,
             "rows": [
                 {"id":"1","key":"jpg","value":null},
                 {"id":"2","key":"jpg","value":null},
              ]
         }




               will leinweber — bitfission.com — merge.fm — @leinweber
//reduce
//map

function(doc) {                                function(keys,values,rereduce) {
  emit("size",doc.info.size);                    return sum(values);
}                                              }



id       key     value
 1      "size"   12345                  {
 2      "size"   32091                      "rows": [
                         reduced
 3      "size"   1253                           {"key":"size","value":238208}
                         238208
 4      "size"   92834                       ]
 5      "size"   49287                  }
 6      "size"   50398




                    will leinweber — bitfission.com — merge.fm — @leinweber
//reduce
//map

function(doc) {                               function(keys,values,rereduce) {
  emit(doc.user, 1);                            return sum(values);
}                                             }



id       key value reduced             {
 1      "bob"   1                          "rows": [
 2      "bob"   1    2                         {"key":"bob","value":2},
 3      "john" 1                               {"key":"john","value":3},
 4      "john" 1     3                         {"key":"zztop","value":1}
 5      "john" 1                            ]
 6      "zztop" 1    1                 }




                   will leinweber — bitfission.com — merge.fm — @leinweber
last example:
complex keys


   will leinweber — bitfission.com — merge.fm — @leinweber
{"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon",
    "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]}
{"_id":2,"name":"trees.jpg","user":"john","camera":"canon",
    "info":{"width":30,"height":250,"size":32091},"tags":["oak"]}
{"_id":3,"name":"snow.png","user":"john","camera":"canon",
    "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]}
{"_id":4,"name":"hawaii.png","user":"john","camera":"nikon",
    "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]}
{"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon",
    "info":{"width":320,"height":128,"size":49287},"tags":["maui"]}
{"_id":6,"name":"island.gif","user":"zztop","camera":"nikon",
    "info":{"width":640,"height":480,"size":50398},"tags":["maui"]}




                   will leinweber — bitfission.com — merge.fm — @leinweber
//map                                           //reduce
function(doc) {                                 function(keys,values,rereduce){
  emit([doc.user,doc.camera],1);                  return sum(values);
}                                               }



id key            value reduced {
                                  "rows": [
5 ["bob","canon"]    1     1
                                   {"key":["bob","canon"],"value":1},
1 ["bob","nikon"]    1     1        {"key":["bob","nikon"],"value":1},
2 ["john","canon"] 1                {"key":["john","canon"],"value":2},
                           2
3 ["john","canon"] 1                {"key":["john","nikon"],"value":1},
4 ["john","nikon"] 1       1        {"key":["zztop","nikon"],"value":1}
                                   ]
6 ["zztop","nikon"] 1      1
                                         }




                 will leinweber — bitfission.com — merge.fm — @leinweber
//map                                            //reduce
function(doc) {                                  function(keys,values,rereduce){
  emit([doc.user,doc.camera],1);                   return sum(values);
}                                                }


                  ?startkey=[“bob”]&endkey=[“bob”,{}]

              {
                "rows": [
                 {"key":["bob","canon"],"value":1},
                  {"key":["bob","nikon"],"value":1},
                 ]
              }




                  will leinweber — bitfission.com — merge.fm — @leinweber
views are saved
b+ trees


   will leinweber — bitfission.com — merge.fm — @leinweber
updated when
accessed


   will leinweber — bitfission.com — merge.fm — @leinweber
updated
incrementally


   will leinweber — bitfission.com — merge.fm — @leinweber
couchrest



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
couchrest core



   will leinweber — bitfission.com — merge.fm — @leinweber
DB = CouchRest.database!("temps")

DB.save_doc "_id" => "room1", "temps" => [34]
#=> {"rev"=>"1-3b4f6c5218621d8876", "id"=>"room1", "ok"=>true}

room = DB.get "room1"
#=> {"temps"=>[34], "_rev"=>"1-3b4f6c5218621", "_id"=>"room1"}
room["temps"] << 35 << 25 << 33 << 25

room.save
#=> {"temps"=>[34,35,25,33,25],"_rev"=>"2-1d15c4a8a","_id"=>"room1"}




                will leinweber — bitfission.com — merge.fm — @leinweber
DB.view("temps/temp", :key=>25)
#=> {"total_rows"=>5, "rows"=>[
        {"id"=>"room1", "value"=>{...}, "key"=>25}
   ]}




             will leinweber — bitfission.com — merge.fm — @leinweber
Extended
Document


   will leinweber — bitfission.com — merge.fm — @leinweber
class User < CouchRest::ExtendedDocument
  property :name
  property :email
  property :posts, :default => [], :accessible => true
  timestamps!
  view_by :name
  view_by :post_ids,
    :map => %Q("function(doc) {
      if (doc['couchrest-type']=='User' && doc.post_ids){...)
  validates_with_method :name, :valid_name?
  validates_presence_of :email
  before_save :update_posts
end




              will leinweber — bitfission.com — merge.fm — @leinweber
get couchdb



   will leinweber — bitfission.com — merge.fm — @leinweber
homebrew
couchdbx
build

  will leinweber — bitfission.com — merge.fm — @leinweber
links



    will leinweber — bitfission.com — merge.fm — @leinweber
couchdb.apache.org
books.couchdb.org
github.com/couchrest
bit.ly/jscouchdb

    will leinweber — bitfission.com — merge.fm — @leinweber
thanks



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
Olaf Alders
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecture
zefhemel
 

Was ist angesagt? (20)

MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
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)
 
FalcorJS
FalcorJSFalcorJS
FalcorJS
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutines
 
Kotlin coroutines
Kotlin coroutines Kotlin coroutines
Kotlin coroutines
 
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecture
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI
 

Ähnlich wie CouchDB @ red dirt ruby conference

CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
Jason Davies
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
yiming he
 

Ähnlich wie CouchDB @ red dirt ruby conference (20)

Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 Refresher
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboard
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
Tabledown
TabledownTabledown
Tabledown
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
 
Webinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsWebinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation Options
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
 
MongoDB
MongoDBMongoDB
MongoDB
 
Modeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databasesModeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databases
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
Latinoware
LatinowareLatinoware
Latinoware
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

CouchDB @ red dirt ruby conference

  • 1. couchdb, ruby, and you. will leinweber — bitfission.com — merge.fm — @leinweber
  • 2. will leinweber will leinweber — bitfission.com — merge.fm — @leinweber
  • 3. couchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 4. will leinweber — bitfission.com — merge.fm — @leinweber
  • 5. will leinweber — bitfission.com — merge.fm — @leinweber
  • 6. documents will leinweber — bitfission.com — merge.fm — @leinweber
  • 7. json will leinweber — bitfission.com — merge.fm — @leinweber
  • 8. rich documents will leinweber — bitfission.com — merge.fm — @leinweber
  • 9. { "_id": "will", "_rev": "3-4352629382", "fullname": "Will Leinweber", "email": "will@bitfission.com", "sites": [ {"blog": "bitfission.com", "hits": 42}, {"github": "github.com/will"}, {"twitter": "twitter.com/leinweber"}, {"company": "merge.fm"} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 10. schemaless will leinweber — bitfission.com — merge.fm — @leinweber
  • 11. http api will leinweber — bitfission.com — merge.fm — @leinweber
  • 12. restful will leinweber — bitfission.com — merge.fm — @leinweber
  • 13. ~% curl localhost:5984/appdb/docid {"_id":"docid","_rev":"2-3779119708","look":"at all this data","its_awesome":true} will leinweber — bitfission.com — merge.fm — @leinweber
  • 14. ~% curl localhost:5984/appdb/docid -i HTTP/1.1 200 OK Server: CouchDB/0.11.0 (Erlang OTP/R13B) Etag: "2-3779119708" Date: Wed, 28 Apr 2010 06:46:42 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 83 Cache-Control: must-revalidate will leinweber — bitfission.com — merge.fm — @leinweber
  • 15. caching will leinweber — bitfission.com — merge.fm — @leinweber
  • 16. clustering will leinweber — bitfission.com — merge.fm — @leinweber
  • 17. replication will leinweber — bitfission.com — merge.fm — @leinweber
  • 18. couchapps! will leinweber — bitfission.com — merge.fm — @leinweber
  • 19. views will leinweber — bitfission.com — merge.fm — @leinweber
  • 20. javascript map/reduce will leinweber — bitfission.com — merge.fm — @leinweber
  • 21. map will leinweber — bitfission.com — merge.fm — @leinweber
  • 22. bit.ly/jscouchdb example will leinweber — bitfission.com — merge.fm — @leinweber
  • 23. {"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon", "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]} {"_id":2,"name":"trees.jpg","user":"john","camera":"canon", "info":{"width":30,"height":250,"size":32091},"tags":["oak"]} {"_id":3,"name":"snow.png","user":"john","camera":"canon", "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]} {"_id":4,"name":"hawaii.png","user":"john","camera":"nikon", "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]} {"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon", "info":{"width":320,"height":128,"size":49287},"tags":["maui"]} {"_id":6,"name":"island.gif","user":"zztop","camera":"nikon", "info":{"width":640,"height":480,"size":50398},"tags":["maui"]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 24. function(doc) { emit(doc.user, null); } { "total_rows": 6, "rows": [ {"id":"1","key":"bob","value":null}, {"id":"5","key":"bob","value":null}, {"id":"2","key":"john","value":null}, {"id":"3","key":"john","value":null}, {"id":"4","key":"john","value":null}, {"id":"6","key":"zztop","value":null} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 25. function(doc) { emit(doc.name.match(/w+.(w{3})/)[1], null); } { "total_rows": 6, "rows": [ {"id":"5","key":"gif","value":null}, {"id":"6","key":"gif","value":null}, {"id":"1","key":"jpg","value":null}, {"id":"2","key":"jpg","value":null}, {"id":"3","key":"png","value":null}, {"id":"4","key":"png","value":null} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 26. function(doc) { emit(doc.name.match(/w+.(w{3})/)[1], null); } ?key="jpg" { "total_rows": 2, "rows": [ {"id":"1","key":"jpg","value":null}, {"id":"2","key":"jpg","value":null}, ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 27. //reduce //map function(doc) { function(keys,values,rereduce) { emit("size",doc.info.size); return sum(values); } } id key value 1 "size" 12345 { 2 "size" 32091     "rows": [ reduced 3 "size" 1253         {"key":"size","value":238208} 238208 4 "size" 92834      ] 5 "size" 49287 } 6 "size" 50398 will leinweber — bitfission.com — merge.fm — @leinweber
  • 28. //reduce //map function(doc) { function(keys,values,rereduce) { emit(doc.user, 1); return sum(values); } } id key value reduced { 1 "bob" 1     "rows": [ 2 "bob" 1 2         {"key":"bob","value":2}, 3 "john" 1         {"key":"john","value":3}, 4 "john" 1 3         {"key":"zztop","value":1} 5 "john" 1      ] 6 "zztop" 1 1 } will leinweber — bitfission.com — merge.fm — @leinweber
  • 29. last example: complex keys will leinweber — bitfission.com — merge.fm — @leinweber
  • 30. {"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon", "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]} {"_id":2,"name":"trees.jpg","user":"john","camera":"canon", "info":{"width":30,"height":250,"size":32091},"tags":["oak"]} {"_id":3,"name":"snow.png","user":"john","camera":"canon", "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]} {"_id":4,"name":"hawaii.png","user":"john","camera":"nikon", "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]} {"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon", "info":{"width":320,"height":128,"size":49287},"tags":["maui"]} {"_id":6,"name":"island.gif","user":"zztop","camera":"nikon", "info":{"width":640,"height":480,"size":50398},"tags":["maui"]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 31. //map //reduce function(doc) { function(keys,values,rereduce){ emit([doc.user,doc.camera],1); return sum(values); } } id key value reduced { "rows": [ 5 ["bob","canon"] 1 1    {"key":["bob","canon"],"value":1}, 1 ["bob","nikon"] 1 1     {"key":["bob","nikon"],"value":1}, 2 ["john","canon"] 1     {"key":["john","canon"],"value":2}, 2 3 ["john","canon"] 1     {"key":["john","nikon"],"value":1}, 4 ["john","nikon"] 1 1     {"key":["zztop","nikon"],"value":1}    ] 6 ["zztop","nikon"] 1 1 } will leinweber — bitfission.com — merge.fm — @leinweber
  • 32. //map //reduce function(doc) { function(keys,values,rereduce){ emit([doc.user,doc.camera],1); return sum(values); } } ?startkey=[“bob”]&endkey=[“bob”,{}] { "rows": [    {"key":["bob","canon"],"value":1},     {"key":["bob","nikon"],"value":1},    ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 33. views are saved b+ trees will leinweber — bitfission.com — merge.fm — @leinweber
  • 34. updated when accessed will leinweber — bitfission.com — merge.fm — @leinweber
  • 35. updated incrementally will leinweber — bitfission.com — merge.fm — @leinweber
  • 36. couchrest will leinweber — bitfission.com — merge.fm — @leinweber
  • 37. will leinweber — bitfission.com — merge.fm — @leinweber
  • 38. couchrest core will leinweber — bitfission.com — merge.fm — @leinweber
  • 39. DB = CouchRest.database!("temps") DB.save_doc "_id" => "room1", "temps" => [34] #=> {"rev"=>"1-3b4f6c5218621d8876", "id"=>"room1", "ok"=>true} room = DB.get "room1" #=> {"temps"=>[34], "_rev"=>"1-3b4f6c5218621", "_id"=>"room1"} room["temps"] << 35 << 25 << 33 << 25 room.save #=> {"temps"=>[34,35,25,33,25],"_rev"=>"2-1d15c4a8a","_id"=>"room1"} will leinweber — bitfission.com — merge.fm — @leinweber
  • 40. DB.view("temps/temp", :key=>25) #=> {"total_rows"=>5, "rows"=>[ {"id"=>"room1", "value"=>{...}, "key"=>25} ]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 41. Extended Document will leinweber — bitfission.com — merge.fm — @leinweber
  • 42. class User < CouchRest::ExtendedDocument property :name property :email property :posts, :default => [], :accessible => true timestamps! view_by :name view_by :post_ids, :map => %Q("function(doc) { if (doc['couchrest-type']=='User' && doc.post_ids){...) validates_with_method :name, :valid_name? validates_presence_of :email before_save :update_posts end will leinweber — bitfission.com — merge.fm — @leinweber
  • 43. get couchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 44. homebrew couchdbx build will leinweber — bitfission.com — merge.fm — @leinweber
  • 45. links will leinweber — bitfission.com — merge.fm — @leinweber
  • 46. couchdb.apache.org books.couchdb.org github.com/couchrest bit.ly/jscouchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 47. thanks will leinweber — bitfission.com — merge.fm — @leinweber
  • 48. will leinweber — bitfission.com — merge.fm — @leinweber

Hinweis der Redaktion