SlideShare a Scribd company logo
1 of 83
riak-js




JavaScript turtles all the way down
           Sean Cribbs

         http://whenchemistsattack.com/2008/04/25/turtles-all-the-way-down/
Browser


 Server


    DB
Browser   JavaScript


        Java, Ruby,
 Server
        PHP, Python


    DB       SQL
Browser   JavaScript   JavaScript


        Java, Ruby,
 Server                 node.js
        PHP, Python


    DB       SQL          SQL
Browser   JavaScript   JavaScript   JavaScript


        Java, Ruby,
 Server                 node.js       node.js
        PHP, Python


    DB       SQL          SQL       JavaScript?!
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/
What about Couch?
 It has JavaScript.
http://captainwildchild.blogspot.com/2011/04/stopping-for-turtles.html




What about Couch?
 It has JavaScript.
http://www.comicbookmovie.com/teenage_mutant_ninja_turtles/news/?a=18553




What about Couch?
 It has JavaScript.
What is Riak?
What is Riak?


• Distributed,
  Fault-Tolerant,
  Replicated
What is Riak?


• Distributed,
  Fault-Tolerant,
  Replicated

• Scales out linearly
What is Riak?


• Distributed,
  Fault-Tolerant,
  Replicated

• Scales out linearly
• Flexible data
  model
What is Riak?


• Distributed,
  Fault-Tolerant,
  Replicated

• Scales out linearly
• Flexible data
  model
What is Riak?

                       PLUS
                            IPT!
• Distributed,      JAVASCR
  Fault-Tolerant,
  Replicated

• Scales out linearly
• Flexible data
  model
riakjs.org
Getting Started
Getting Started
 Install Riak or Riak Search:
http://downloads.basho.com
Getting Started
    Install Riak or Riak Search:
   http://downloads.basho.com

$ npm install riak-js@latest
Getting Started
    Install Riak or Riak Search:
   http://downloads.basho.com

$ npm install riak-js@latest
$ git clone git://github.com/frank06/riak-js
Getting Started
    Install Riak or Riak Search:
   http://downloads.basho.com

$ npm install riak-js@latest
$ git clone git://github.com/frank06/riak-js
Basic Client
Operations
               http://ijustwanttofitin.com/tag/rally-cars/
Basic Operations
Basic Operations
// Get a client (pass options if needed)
var db = require('riak-js').getClient()
Basic Operations
// Get a client (pass options if needed)
var db = require('riak-js').getClient()

// Fetch an object
db.get('conferences', 'nodeconf',
  function(err, data) {
    console.log("Found the conference:" +
                sys.inspect(data))
  })
Basic Operations
// Get a client (pass options if needed)
var db = require('riak-js').getClient()

// Fetch an object                    typical node
db.get('conferences', 'nodeconf',    callback style
  function(err, data) {
    console.log("Found the conference:" +
                sys.inspect(data))
  })
Basic Operations
// Get a client (pass options if needed)
var db = require('riak-js').getClient()

// Fetch an object                    typical node
db.get('conferences', 'nodeconf',    callback style
  function(err, data) {
    console.log("Found the conference:" +
                sys.inspect(data))
  })

// Store an object
db.save('conferences', 'nodeconf',
        {date:"2011-05-05",
         title: "nodeconf 2011",
         presenters: ["Sean Cribbs"]})
Basic Operations




           Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.remove('conferences', 'nodeconf')




                                       Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.remove('conferences', 'nodeconf')

// Does this key exist?
db.exists('frameworks', 'node.js')

// Stream the keys (on master)




                                       Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.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
Basic Operations
// Delete an object
db.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 all
db.getAll('frameworks')




                                         Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.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 all
db.getAll('frameworks')




                                         Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.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 all
db.getAll('frameworks')

// How many are there? (counts keys)




                                         Picture: http://www.scooponpets.com/Turtlesaspets.html
Basic Operations
// Delete an object
db.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 all
db.getAll('frameworks')

// How many are there? (counts keys)
db.count('frameworks')



                                         Picture: http://www.scooponpets.com/Turtlesaspets.html
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)
    function cb(err, data, META){ }




          Picture: http://chronotron.files.wordpress.com/2010/07/turtles.png
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)

  • Request-time metadata
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)

  • Request-time metadata
   •contentType
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)

  • Request-time metadata
   •contentType
   •clientId
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)

  • Request-time metadata
   •contentType
   •clientId
   • links, usermeta
Meta Object
db.save(‘bucket’, ‘key’, data, META, cb)

  • Request-time metadata
   •contentType
   •clientId
   • links, usermeta
   • quorums (r,w,dw), returnBody
Meta Object
function cb(err, data, META){ }
Meta Object
 function cb(err, data, META){ }


• Response-time metadata
Meta Object
 function cb(err, data, META){ }


• Response-time metadata
 • bucket, key, vclock
Meta Object
 function cb(err, data, META){ }


• Response-time metadata
 • bucket, key, vclock
 • links, usermeta
Meta Object
 function cb(err, data, META){ }


• Response-time metadata
 • bucket, key, vclock
 • links, usermeta
 • lastMod, etag, statusCode
Using Meta
Using Meta
// Add a link to the object
db.get('frameworks', 'node.js',
  function(err, data, meta){
    meta.addLink({bucket:'vm', key:'v8', tag:'vm'});
    db.save('frameworks', 'node.js', data, meta)
  })
Using Meta
// Add a link to the object
db.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 type
db.save('pages', 'index.html',
        '<html><body>Hello, world!</body></html>',
        {contentType: 'html'})
Querying Beyond
  Key-Value




   Picture: http://greencs.files.wordpress.com/2008/07/turtle-
                              nom.jpg
Link-walking




      Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al-
                                     aquarium.html
Link-walking
// Find friends
db.walk('people', 'sean',
        [['_','friend']])




                            Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al-
                                                           aquarium.html
Link-walking
// Find friends
db.walk('people', 'sean',
        [['_','friend']])

// Find acquaintances of friends
db.walk('people', 'mathias',
        [['_','friend'],




                            Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al-
                                                           aquarium.html
Link-walking
// Find friends
db.walk('people', 'sean',
        [['_','friend']])

// Find acquaintances of friends
db.walk('people', 'mathias',
        [['_','friend'],
         ['people','_']])




                            Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al-
                                                           aquarium.html
Wait. You said Riak
had JavaScript in it!


                                           U MAD?


      Picture: http://arsnotoria.blogspot.com/2010_04_18_archive.html
MapReduce
MapReduce
  list of keys
MapReduce
                 list of keys



map()    map()      map()       map()   map()
MapReduce
                 list of keys



map()    map()      map()       map()   map()




                   reduce()
MapReduce
                 list of keys



map()    map()      map()       map()   map()




                   reduce()



                   results
MapReduce
                 list of keys
                       JSON



map()    map()      map()       map()   map()




                   reduce()



                   results
MapReduce
                            list of keys
                                  JSON



       map()       map()       map()       map()     map()
JavaScript     JavaScript     JavaScript     JavaScript      JavaScript



                              reduce()



                              results
MapReduce
                            list of keys
                                  JSON



       map()       map()       map()       map()     map()
JavaScript     JavaScript     JavaScript     JavaScript      JavaScript



                              reduce()
                              JavaScript

                              results
MapReduce
                            list of keys
                                  JSON



       map()       map()       map()       map()     map()
JavaScript     JavaScript     JavaScript     JavaScript      JavaScript



                              reduce()
                              JavaScript

                              results

                                  JSON
MapReduce
MapReduce
// Execute a MapReduce query
db.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);
       })
MapReduce
// Execute a MapReduce query
db.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 query
db.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()
MapReduce
MapReduce

// Initiate MapReduce with a key-filter
db.add({ bucket: 'emails',
         key_filters: [["ends_with", "basho.com"]] })
   // Map with a phase-argument
  .map({ name:'Riak.mapByFields',
         arg: { joined:'2010-01-01' })
  .run()
Riak Search
Riak Search

// Turn on automatic document indexing
db.enableIndex('documents')
Riak Search

// Turn on automatic document indexing
db.enableIndex('documents')

// Perform a simple search
db.search('documents', 'title:scalable')
Riak Search

// Turn on automatic document indexing
db.enableIndex('documents')

// Perform a simple search
db.search('documents', 'title:scalable')

// Start a MapReduce query with search
db.addSearch('documents', 'title:scalable')
// From here, add map and reduce phases
etc.
etc.

• Session Store
etc.

• Session Store
• Mini-Riak Test Server
etc.

• Session Store
• Mini-Riak Test Server
• Multi-protocol (HTTP, Protobuffs)
etc.

• Session Store
• Mini-Riak Test Server
• Multi-protocol (HTTP, Protobuffs)
• Luwak (large files)
COME AT ME BRO




   Picture: http://fl.biology.usgs.gov/posters/Herpetology/Snapping_Turtles/snapping_turtles.html




            Demo Time
https://github.com/basho/riaktant
Questions?
Questions?
     sean@basho.com
       @seancribbs


    jsconf.basho.com
Riak on Turtles



                           (someday)


Picture: http://scienceblogs.com/bioephemera/2008/07/gpsequipped_box_turtle_leads_p.php

More Related Content

More from Sean Cribbs

The Radiant Ethic
The Radiant EthicThe Radiant Ethic
The Radiant EthicSean Cribbs
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Sean Cribbs
 
Schema Design for Riak
Schema Design for RiakSchema Design for Riak
Schema Design for RiakSean Cribbs
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingSean Cribbs
 
Introducing Riak and Ripple
Introducing Riak and RippleIntroducing Riak and Ripple
Introducing Riak and RippleSean Cribbs
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallySean Cribbs
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangSean Cribbs
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And DragonsSean Cribbs
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for RubyistsSean Cribbs
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainSean Cribbs
 

More from Sean Cribbs (12)

The Radiant Ethic
The Radiant EthicThe Radiant Ethic
The Radiant Ethic
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)
 
Riak with Rails
Riak with RailsRiak with Rails
Riak with Rails
 
Schema Design for Riak
Schema Design for RiakSchema Design for Riak
Schema Design for Riak
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf Training
 
Introducing Riak and Ripple
Introducing Riak and RippleIntroducing Riak and Ripple
Introducing Riak and Ripple
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And Dragons
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for Rubyists
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

riak-js: Javascript Turtles All the Way Down

  • 1. riak-js JavaScript turtles all the way down Sean Cribbs http://whenchemistsattack.com/2008/04/25/turtles-all-the-way-down/
  • 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.
  • 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
  • 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 Client Operations http://ijustwanttofitin.com/tag/rally-cars/
  • 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 object db.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 node db.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 node db.get('conferences', 'nodeconf', callback style   function(err, data) {     console.log("Found the conference:" + sys.inspect(data))   }) // Store an object db.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 object db.remove('conferences', 'nodeconf') Picture: http://www.scooponpets.com/Turtlesaspets.html
  • 30. Basic Operations // Delete an object db.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 object db.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 object db.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 all db.getAll('frameworks') Picture: http://www.scooponpets.com/Turtlesaspets.html
  • 33. Basic Operations // Delete an object db.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 all db.getAll('frameworks') Picture: http://www.scooponpets.com/Turtlesaspets.html
  • 34. Basic Operations // Delete an object db.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 all db.getAll('frameworks') // How many are there? (counts keys) Picture: http://www.scooponpets.com/Turtlesaspets.html
  • 35. Basic Operations // Delete an object db.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 all db.getAll('frameworks') // How many are there? (counts keys) db.count('frameworks') Picture: http://www.scooponpets.com/Turtlesaspets.html
  • 36. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) function cb(err, data, META){ } Picture: http://chronotron.files.wordpress.com/2010/07/turtles.png
  • 38. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata
  • 39. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType
  • 40. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId
  • 41. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId • links, usermeta
  • 42. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time metadata •contentType •clientId • links, usermeta • quorums (r,w,dw), returnBody
  • 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
  • 49. Using Meta // Add a link to the object db.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 object db.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 type db.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 friends db.walk('people', 'sean', [['_','friend']]) Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
  • 54. Link-walking // Find friends db.walk('people', 'sean', [['_','friend']]) // Find acquaintances of friends db.walk('people', 'mathias',         [['_','friend'], Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
  • 55. Link-walking // Find friends db.walk('people', 'sean', [['_','friend']]) // Find acquaintances of friends db.walk('people', 'mathias',         [['_','friend'],          ['people','_']]) Picture: http://fisherwy.blogspot.com/2007/09/two-headed-turtle-at-big-al- aquarium.html
  • 56. Wait. You said Riak had JavaScript in it! U MAD? Picture: http://arsnotoria.blogspot.com/2010_04_18_archive.html
  • 58. MapReduce list of keys
  • 59. MapReduce list of keys map() map() map() map() map()
  • 60. MapReduce list of keys map() map() map() map() map() reduce()
  • 61. MapReduce list of keys map() map() map() map() map() reduce() results
  • 62. MapReduce list of keys JSON map() 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
  • 67. MapReduce // Execute a MapReduce query db.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 query db.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 query db.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()
  • 70. MapReduce // Initiate MapReduce with a key-filter db.add({ bucket: 'emails',          key_filters: [["ends_with", "basho.com"]] }) // Map with a phase-argument   .map({ name:'Riak.mapByFields',          arg: { joined:'2010-01-01' })   .run()
  • 72. Riak Search // Turn on automatic document indexing db.enableIndex('documents')
  • 73. Riak Search // Turn on automatic document indexing db.enableIndex('documents') // Perform a simple search db.search('documents', 'title:scalable')
  • 74. Riak Search // Turn on automatic document indexing db.enableIndex('documents') // Perform a simple search db.search('documents', 'title:scalable') // Start a MapReduce query with search db.addSearch('documents', 'title:scalable') // From here, add map and reduce phases
  • 75. etc.
  • 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 Time https://github.com/basho/riaktant
  • 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

Editor's Notes

  1. \n
  2. Like all these turtles marching toward the sea, we&amp;#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&amp;#x2019;t been before.\n
  3. Like all these turtles marching toward the sea, we&amp;#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&amp;#x2019;t been before.\n
  4. Like all these turtles marching toward the sea, we&amp;#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&amp;#x2019;t been before.\n
  5. Like all these turtles marching toward the sea, we&amp;#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&amp;#x2019;t been before.\n
  6. So you&amp;#x2019;re probably saying &amp;#x201C;What about CouchDB? It has JavaScript&amp;#x201D;. \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&amp;#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  7. So you&amp;#x2019;re probably saying &amp;#x201C;What about CouchDB? It has JavaScript&amp;#x201D;. \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&amp;#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  8. So you&amp;#x2019;re probably saying &amp;#x201C;What about CouchDB? It has JavaScript&amp;#x201D;. \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&amp;#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  9. So you&amp;#x2019;re probably saying &amp;#x201C;What about CouchDB? It has JavaScript&amp;#x201D;. \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&amp;#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
  10. * &amp;#x201C;Your data is safe with us.&amp;#x201D;\n* &amp;#x201C;Just add more machines.&amp;#x201D;\n* &amp;#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&amp;#x201D;\n
  11. * &amp;#x201C;Your data is safe with us.&amp;#x201D;\n* &amp;#x201C;Just add more machines.&amp;#x201D;\n* &amp;#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&amp;#x201D;\n
  12. * &amp;#x201C;Your data is safe with us.&amp;#x201D;\n* &amp;#x201C;Just add more machines.&amp;#x201D;\n* &amp;#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&amp;#x201D;\n
  13. * &amp;#x201C;Your data is safe with us.&amp;#x201D;\n* &amp;#x201C;Just add more machines.&amp;#x201D;\n* &amp;#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&amp;#x201D;\n
  14. * &amp;#x201C;Your data is safe with us.&amp;#x201D;\n* &amp;#x201C;Just add more machines.&amp;#x201D;\n* &amp;#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&amp;#x201D;\n
  15. So if you want to work with Riak from node.js, Francisco Treacy &lt;point him out&gt; wrote this awesome driver called riak-js. It&amp;#x2019;s also got a beautiful website at riakjs.org that is envy of all READMEs.\n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  22. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  23. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  24. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  25. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  26. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  27. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  28. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  29. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  30. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  31. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  32. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  33. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  34. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  35. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  36. Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. Hosted on no.de\n
  122. \n
  123. \n
  124. \n