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