0
Introduction to
Riak & Ripple
      Sean Cribbs
basho Developer Advocate
Introduction to
Riak & Ripple
      Sean Cribbs
basho Developer Advocate

                    Rubyist, Evangelist,
       ...
Riak @10,000 ft.
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-...
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-...
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-...
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-...
Dynamo-like
 Scalability
Dynamo-like
       Scalability
• To get...
Dynamo-like
      Scalability
• To get...
 • more storage,
Dynamo-like
      Scalability
• To get...
 • more storage,
 • more throughput,
Dynamo-like
      Scalability
• To get...
 • more storage,
 • more throughput,
 • lower latency...
Dynamo-like
       Scalability
• To get...
 • more storage,
 • more throughput,
 • lower latency...
• ...add more machines...
Key-Value++
Key-Value++
• Data objects are identified by keys,
  and have metadata
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
• Links enable lightw...
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
• Links enable lightw...
Sans-Schema
Sans-Schema
• Buckets created on the fly
Sans-Schema
• Buckets created on the fly
• Values are opaque
Sans-Schema
• Buckets created on the fly
• Values are opaque
•Content-Type matters
Sans-Schema
• Buckets created on the fly
• Values are opaque
•Content-Type matters
•The application defines the
 semantics:
...
Web-Friendly
Web-Friendly
•HTTP is primary interface
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions

•...
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions

•...
Use Cases
Use Cases
•Document storage
 (sparse structure)
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
•Dis...
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
•Dis...
Getting Started
Getting Started
• Download a package from
 http://downloads.basho.com
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
• Joi...
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
• Joi...
Riak in Ruby
Riak in Ruby
• Three gems
Riak in Ruby
• Three gems
 • riak-client (basic ops)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
 • riak-sessions
   (Rack/Rails session stores)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
 • riak-sessions
   (Rack/Rails session stores)

• Al...
require ‘riak’
require ‘riak’
• Make a client object
 client = Riak::Client.new
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bu...
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bu...
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bu...
Riak::RObject
Riak::RObject
•Get/set object key
 obj.key = “bar”
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’

•Get/set...
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’

•Get/set...
More RObject
More RObject
•Get object’s bucket
 obj.bucket
More RObject
•Get object’s bucket
 obj.bucket

•Delete the object
 obj.delete # freezes the object
More RObject
•Get object’s bucket
  obj.bucket

•Delete the object
  obj.delete # freezes the object

•Detect/extract sibl...
More RObject
•Get object’s bucket
  obj.bucket

•Delete the object
  obj.delete # freezes the object

•Detect/extract sibl...
Riak::Bucket
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # nu...
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # nu...
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # nu...
Links: Lightweight
Relationships
Link Header


Link: </riak/demo/test1>; riaktag=”userinfo”
Link Header

          bucket

Link: </riak/demo/test1>; riaktag=”userinfo”
Link Header

          bucket

Link: </riak/demo/test1>; riaktag=”userinfo”


                  key
Link Header

          bucket                       tag

Link: </riak/demo/test1>; riaktag=”userinfo”


                  ...
Links in Ruby API
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
            “tag”)
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
            “tag”)

• Read an#object’s links
  obj....
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
              “tag”)

• Read an#object’s links
  ob...
Link-Walking
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
• Can return results fr...
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
• Can return results fr...
L/W Example
L/W Example
GET /riak/demo/test1/_,friend,1

Start at demo/test1, follow all links
tagged “friend” and return the objects
...
L/W Example
GET /riak/demo/test1/_,friend,1

Start at demo/test1, follow all links
tagged “friend” and return the objects
...
L/W Example
L/W Example
GET /riak/demo/test1/_,_,_/_,_,1

Start at demo/test1, follow all links,
follow all links from those, return
e...
Map-Reduce
list of keys




Map-Reduce
list of keys



map    map       map        map   map




      Map-Reduce
list of keys



map    map       map        map   map




                reduce




      Map-Reduce
list of keys



map    map       map        map   map




                reduce



               results



      Map-Re...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                        in Javascript

         Riak object

function(value, keyData, arg) {
    var object = Riak.map...
Map
                            in Javascript

         Riak object

function(value, keyData, arg) {
    var object = Riak...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                        in Javascript
                  Key-specific
                     data

function(value, keyData...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                        in Javascript
                             Phase-
                           specific data
func...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                       in Javascript


function(value, keyData, arg) {             Parse JSON data
    var object = Ri...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                         in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0]...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                         in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0]...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Map
                          in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0...
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];...
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      retur...
Reduce
                         in Javascript


         Map results

function(values,arg) {
    return values.sort(functi...
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      retur...
Reduce
                         in Javascript


                  Phase-
                specific data

function(values,arg...
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      retur...
Reduce
                        in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return...
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      retur...
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      retur...
Example Query
Example Query
{“inputs”: “goog”,
“query”: [{“map”:{“language”:”javascript”,
            “name”: “App.findHighGreater”,
    ...
Example Query
{“inputs”: “goog”,
 “query”: [{“map”:{“language”:”javascript”,
             “name”: “App.findHighGreater”,
  ...
Built-in Functions
Built-in Functions
• Riak.mapValues
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
• Riak.reduceSort
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
• Riak.reduceSort
• Riak.redu...
Ripple - ODM
Document Models
class Person
 include Ripple::Document

 property :name, String, :presence => true
 many :addresses
 many ...
Rails Setup
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'


$ gem install curb yajl-rub...
Rails Setup (cont.)
Rails Setup (cont.)
# config/ripple.yml
development:
 host: 127.0.0.1
 port: 8098
Rails Setup (cont.)
# config/ripple.yml
development:
 host: 127.0.0.1
 port: 8098


# config/application.rb
require 'ripple/...
Ripple Roadmap
Ripple Roadmap
• Testing server (edge on Github)
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
• Ripple-specific built-i...
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
• Ripple-specific built-i...
Happy Fun
Demo Time
Plug




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.co...
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.co...
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.co...
Questions
Upcoming SlideShare
Loading in...5
×

Introduction to Riak and Ripple (KC.rb)

3,759

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,759
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
58
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
































































































































  • Transcript of "Introduction to Riak and Ripple (KC.rb)"

    1. 1. Introduction to Riak & Ripple Sean Cribbs basho Developer Advocate
    2. 2. Introduction to Riak & Ripple Sean Cribbs basho Developer Advocate Rubyist, Evangelist, Support Monkey
    3. 3. Riak @10,000 ft.
    4. 4. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly
    5. 5. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document
    6. 6. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document • Schema-less, content-agnostic
    7. 7. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document • Schema-less, content-agnostic • Web-friendly HTTP, JSON, Javascript
    8. 8. Dynamo-like Scalability
    9. 9. Dynamo-like Scalability • To get...
    10. 10. Dynamo-like Scalability • To get... • more storage,
    11. 11. Dynamo-like Scalability • To get... • more storage, • more throughput,
    12. 12. Dynamo-like Scalability • To get... • more storage, • more throughput, • lower latency...
    13. 13. Dynamo-like Scalability • To get... • more storage, • more throughput, • lower latency... • ...add more machines. aka horizontal & linear
    14. 14. Key-Value++
    15. 15. Key-Value++ • Data objects are identified by keys, and have metadata
    16. 16. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets
    17. 17. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets • Links enable lightweight relationships
    18. 18. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets • Links enable lightweight relationships • Query with MapReduce
    19. 19. Sans-Schema
    20. 20. Sans-Schema • Buckets created on the fly
    21. 21. Sans-Schema • Buckets created on the fly • Values are opaque
    22. 22. Sans-Schema • Buckets created on the fly • Values are opaque •Content-Type matters
    23. 23. Sans-Schema • Buckets created on the fly • Values are opaque •Content-Type matters •The application defines the semantics: more flexibility, more responsibility
    24. 24. Web-Friendly
    25. 25. Web-Friendly •HTTP is primary interface
    26. 26. Web-Friendly •HTTP is primary interface •JSON is used for structured data
    27. 27. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions
    28. 28. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions •Plays well with Varnish, Squid, HAProxy, F5, etc.
    29. 29. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions •Plays well with Varnish, Squid, HAProxy, F5, etc. [see also Webmachine]
    30. 30. Use Cases
    31. 31. Use Cases •Document storage (sparse structure)
    32. 32. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon)
    33. 33. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage
    34. 34. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage •Distributed cache
    35. 35. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage •Distributed cache • Browser-only/Mobile Apps
    36. 36. Getting Started
    37. 37. Getting Started • Download a package from http://downloads.basho.com
    38. 38. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs
    39. 39. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node
    40. 40. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node • Join a cluster
    41. 41. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node • Join a cluster • Start storing/retrieving values
    42. 42. Riak in Ruby
    43. 43. Riak in Ruby • Three gems
    44. 44. Riak in Ruby • Three gems • riak-client (basic ops)
    45. 45. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM)
    46. 46. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM) • riak-sessions (Rack/Rails session stores)
    47. 47. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM) • riak-sessions (Rack/Rails session stores) • All HTTP - Protobuffs coming
    48. 48. require ‘riak’
    49. 49. require ‘riak’ • Make a client object client = Riak::Client.new
    50. 50. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket
    51. 51. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket • Get an object from the bucket obj = bucket.get(‘bar’) # Riak::RObject
    52. 52. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket • Get an object from the bucket obj = bucket.get(‘bar’) # Riak::RObject • Initialize a new object obj = bucket.new(‘baz’)
    53. 53. Riak::RObject
    54. 54. Riak::RObject •Get/set object key obj.key = “bar”
    55. 55. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’
    56. 56. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’ •Get/set the object body data obj.data = {“name” => “Sean”}
    57. 57. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’ •Get/set the object body data obj.data = {“name” => “Sean”} •Store the object obj.store
    58. 58. More RObject
    59. 59. More RObject •Get object’s bucket obj.bucket
    60. 60. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object
    61. 61. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object •Detect/extract siblings (more later) obj.conflict? && obj.siblings # Array<RObject>
    62. 62. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object •Detect/extract siblings (more later) obj.conflict? && obj.siblings # Array<RObject> •Follow/traverse links (more later) obj.walk(:tag => “friend”)
    63. 63. Riak::Bucket
    64. 64. Riak::Bucket •Set the replication factor bucket.n_val = 5
    65. 65. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum
    66. 66. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum •List keys bucket.keys # pass block to stream
    67. 67. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum •List keys bucket.keys # pass block to stream •Set consistency flag (allow sibling generation) obj.allow_mult = true
    68. 68. Links: Lightweight Relationships
    69. 69. Link Header Link: </riak/demo/test1>; riaktag=”userinfo”
    70. 70. Link Header bucket Link: </riak/demo/test1>; riaktag=”userinfo”
    71. 71. Link Header bucket Link: </riak/demo/test1>; riaktag=”userinfo” key
    72. 72. Link Header bucket tag Link: </riak/demo/test1>; riaktag=”userinfo” key
    73. 73. Links in Ruby API
    74. 74. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”)
    75. 75. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”) • Read an#object’s links obj.links Set<Riak::Link>
    76. 76. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”) • Read an#object’s links obj.links Set<Riak::Link> • Convert<< obj2.to_link(“next”) obj.links an object to a link obj.store
    77. 77. Link-Walking
    78. 78. Link-Walking • Asks Riak to traverse a sequence of links via special URL
    79. 79. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag
    80. 80. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag • Can return results from intermediate traversals
    81. 81. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag • Can return results from intermediate traversals • Response is nested multipart/mixed (riak-client handles this for you)
    82. 82. L/W Example
    83. 83. L/W Example GET /riak/demo/test1/_,friend,1 Start at demo/test1, follow all links tagged “friend” and return the objects obj = client[‘demo’][‘test1’] obj.walk(:tag => “friend”,:keep => true)
    84. 84. L/W Example GET /riak/demo/test1/_,friend,1 Start at demo/test1, follow all links tagged “friend” and return the objects obj = client[‘demo’][‘test1’] obj.walk(:tag => “friend”,:keep => true)
    85. 85. L/W Example
    86. 86. L/W Example GET /riak/demo/test1/_,_,_/_,_,1 Start at demo/test1, follow all links, follow all links from those, return everything from the last set obj.walk({},{:keep => true})
    87. 87. Map-Reduce
    88. 88. list of keys Map-Reduce
    89. 89. list of keys map map map map map Map-Reduce
    90. 90. list of keys map map map map map reduce Map-Reduce
    91. 91. list of keys map map map map map reduce results Map-Reduce
    92. 92. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    93. 93. Map in Javascript Riak object function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    94. 94. Map in Javascript Riak object function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) { {         if(object[field] != arg[field]) {             return []; bucket:”foo”,         } key:”bar”,     } vclock:”...”,     return [object]; } values:[ {metadata:{...}, data:”....”} ] }
    95. 95. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    96. 96. Map in Javascript Key-specific data function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    97. 97. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    98. 98. Map in Javascript Phase- specific data function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    99. 99. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    100. 100. Map in Javascript function(value, keyData, arg) { Parse JSON data     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    101. 101. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    102. 102. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     } Check field equality     return [object]; }
    103. 103. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    104. 104. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return []; Return nothing if unequal         }     }     return [object]; }
    105. 105. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    106. 106. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; Return the object if all equal }
    107. 107. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
    108. 108. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    109. 109. Reduce in Javascript Map results function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    110. 110. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    111. 111. Reduce in Javascript Phase- specific data function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    112. 112. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    113. 113. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); Custom sort on }
    114. 114. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
    115. 115. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); } Reduce potentially called multiple times!!
    116. 116. Example Query
    117. 117. Example Query {“inputs”: “goog”, “query”: [{“map”:{“language”:”javascript”, “name”: “App.findHighGreater”, “arg”: 600.0, “keep”: false}, {“reduce”:{“language”:”javascript”, “name”: “Riak.reduceMax”, “keep”: true}]}
    118. 118. Example Query {“inputs”: “goog”, “query”: [{“map”:{“language”:”javascript”, “name”: “App.findHighGreater”, “arg”: 600.0, “keep”: false}, {“reduce”:{“language”:”javascript”, “name”: “Riak.reduceMax”, “keep”: true}]} Riak::MapReduce.new(c).add(‘goog’). map(‘App.findHighGreater’, :arg => 600.0). reduce(“Riak.reduceMax”, :keep => true).run
    119. 119. Built-in Functions
    120. 120. Built-in Functions • Riak.mapValues
    121. 121. Built-in Functions • Riak.mapValues • Riak.mapValuesJson
    122. 122. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields
    123. 123. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum
    124. 124. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum • Riak.reduceSort
    125. 125. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum • Riak.reduceSort • Riak.reduceMin/reduceMax
    126. 126. Ripple - ODM
    127. 127. Document Models class Person include Ripple::Document property :name, String, :presence => true many :addresses many :friends, :class => Person end class Address include Ripple::EmbeddedDocument property :street, String end
    128. 128. Rails Setup
    129. 129. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple'
    130. 130. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple'
    131. 131. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple' $ gem install curb yajl-ruby ripple
    132. 132. Rails Setup (cont.)
    133. 133. Rails Setup (cont.) # config/ripple.yml development: host: 127.0.0.1 port: 8098
    134. 134. Rails Setup (cont.) # config/ripple.yml development: host: 127.0.0.1 port: 8098 # config/application.rb require 'ripple/railtie'
    135. 135. Ripple Roadmap
    136. 136. Ripple Roadmap • Testing server (edge on Github)
    137. 137. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support
    138. 138. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce
    139. 139. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce • Ripple-specific built-ins
    140. 140. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce • Ripple-specific built-ins • Better ActionView support (form_for)
    141. 141. Happy Fun Demo Time
    142. 142. Plug basho
    143. 143. Plug Interested in learning about support, consulting, or Enterprise features? basho
    144. 144. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. basho
    145. 145. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. basho
    146. 146. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. www.basho.com sean@basho.com @seancribbs basho
    147. 147. Questions
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×