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

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 

Recently uploaded (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 

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