em-riak 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -13
- data/Rakefile +34 -0
- data/em-riak.gemspec +40 -40
- data/lib/em-riak/basic.rb +363 -315
- data/lib/em-riak/configurations.rb +1 -1
- data/lib/em-riak/grapher.rb +49 -49
- data/lib/em-riak/map_reduce.rb +44 -33
- data/lib/em-riak/model.rb +7 -0
- data/lib/em-riak/secondary_index.rb +68 -62
- data/lib/em-riak/utils.rb +20 -20
- data/lib/em-riak/version.rb +1 -1
- data/spec/unit/all.rb +0 -0
- data/spec/unit/basic.rb +81 -0
- data/spec/unit/core.rb +70 -0
- data/spec/unit/map_reduce.rb +64 -0
- data/spec/unit/secondary_index.rb +46 -0
- metadata +26 -20
data/README.md
CHANGED
@@ -4,7 +4,7 @@ It is a Riak ruby client design for eventmachine.
|
|
4
4
|
### Concept
|
5
5
|
I tried to implement em-riak with goals : Easy to use, ORM, Fast, Flexible, Hybrid.
|
6
6
|
|
7
|
-
###### Easy To use
|
7
|
+
###### Easy To use (ToDo)
|
8
8
|
I tried to use the same behaviors as active-record or sequel.
|
9
9
|
So when you use em-riak, you don't tackling the "Key Design".
|
10
10
|
Instead, just add an extension into your model, and everygthings goes fine.
|
@@ -36,32 +36,66 @@ With Deferrable-aware, you don't block & wait for your I/O.
|
|
36
36
|
member_three.add_tag(:interests,"backpacker","delicious","cocktail","movie")
|
37
37
|
member_three.remove_tag(:interest,"delicious")
|
38
38
|
|
39
|
-
EmRiak.search(:interests, "delicious") #=> {}
|
40
|
-
EmRiak.search(:interests, "movie") #=> {:member=>["member3"]}
|
41
|
-
EmRiak.search(:secondary_index, :interests, "backpacker") #=> same above
|
42
|
-
EmRiak.search(:interests, "backpacker","movie") #=> {:member=>["member2","member3"]}
|
39
|
+
EmRiak.search(:secondary_index, {:bin=>:interests}, "delicious") #=> {}
|
40
|
+
EmRiak.search(:secondary_index, {:bin=>:interests}, "movie") #=> {:member=>["member3"]}
|
41
|
+
EmRiak.search(:secondary_index, {:bin=>:interests}, "backpacker") #=> same above
|
42
|
+
EmRiak.search(:secondary_index, {:bin=>:interests}, "backpacker","movie") #=> {:member=>["member2","member3"]}
|
43
43
|
|
44
44
|
EmRiak::Util.clean_bucket("member") #=> Clean all the data inside bucket
|
45
45
|
|
46
46
|
<br/>
|
47
|
-
|
48
|
-
With asynchornize, you just set following at anywhere :
|
47
|
+
####Work with Async
|
48
|
+
With asynchornize, you just set following at anywhere :
|
49
49
|
|
50
50
|
EmRiak.async=true
|
51
51
|
|
52
52
|
And the code behind will become asynchornize.
|
53
|
-
|
53
|
+
|
54
|
+
|
55
|
+
You can also do dependent async call like following :
|
56
|
+
|
57
|
+
EmRiak.find("xxx",values){ callback_proc_here }
|
58
|
+
EmRiak.create("xxx",values){ callback_proc_here }
|
59
|
+
EmRiak.delete("xxx",values){ callback_proc_here }
|
54
60
|
|
61
|
+
EmRiak.search(:search_mode,{:callback=>callback_proc_here},search_conditions)
|
62
|
+
# or
|
63
|
+
EmRiak.search(:search_mode,{options},search_conditions){ your_call_back }
|
64
|
+
|
65
|
+
Hybrid is also possible :
|
66
|
+
|
67
|
+
EmRiak.create("member5",{:name=>"5",:created_at=>Time.now}){|result| # Async req
|
68
|
+
EmRiak.find("member5"){|member| # Async req
|
69
|
+
EmRiak.destroy(member.riak_key){|result| # Async req
|
70
|
+
EmRiak.create("member5",{:name=>"5",:created_at=>Time.now,:new=>true}) # Direct req
|
71
|
+
member=EmRiak.find("member5") # Direct req
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
55
75
|
|
56
76
|
### Write some map-reduce
|
57
|
-
|
58
|
-
|
77
|
+
Use it directly as following :
|
78
|
+
|
79
|
+
EmRiak::MapReduce.submit({
|
80
|
+
"inputs" => {"bucket"=> "member","index"=> "123", "key"=>["member1","member2","member3"]},
|
81
|
+
"query" => [{"map"=> {"language"=> "erlang", "module"=>"riak_kv_mapreduce", "function"=>""} },
|
82
|
+
{"reduce"=> {"language"=> "erlang", "module"=>"riak_kv_mapreduce", "function"=>"reduce_identity", "keep"=>true} }
|
83
|
+
]})
|
84
|
+
|
85
|
+
|
86
|
+
Deployment the some js & erlang source :
|
87
|
+
|
88
|
+
rake deploy:source:all
|
89
|
+
# or
|
90
|
+
rake deploy:source:js
|
91
|
+
# or
|
92
|
+
rake deploy:source:erl
|
93
|
+
|
59
94
|
|
60
95
|
|
61
96
|
### TO-DO
|
62
|
-
Async with callback block support
|
63
|
-
Map/Reduce
|
64
97
|
Full Text Seacrh
|
65
98
|
Deployment & Management
|
66
99
|
Protocal Buffer Interface
|
67
|
-
ORM with Model
|
100
|
+
ORM with Model
|
101
|
+
Hadoop MapReduce Support
|
data/Rakefile
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
task :default => [:test]
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
namespace :source do
|
7
|
+
desc "Deploy both javascript and erlang map/reduce soure into riak map/reduce folder"
|
8
|
+
task :all do
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Deploy javascript source into riak js_source folder"
|
13
|
+
task :js do
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Deploy erlang source into riak erl_source folder"
|
18
|
+
task :erl do
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :install do
|
25
|
+
namespace :riak do
|
26
|
+
desc "Install riak build from source"
|
27
|
+
task :source do
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Install riak build from source & as development mode"
|
31
|
+
task :dev do
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/em-riak.gemspec
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
s.name = 'em-riak'
|
3
|
+
s.version = '0.2.5'
|
4
|
+
s.date = '2012-12-27'
|
5
|
+
s.summary = "Riak client for eventmachine"
|
6
|
+
s.description = "An extremely fast and convenient riak client for eventmachine."
|
7
|
+
s.authors = ["Von"]
|
8
|
+
s.email = 'von@vonstark.co'
|
9
|
+
s.files = ["lib/em-riak.rb"]
|
10
|
+
s.homepage = 'http://tech.vonstark.co'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
includes = %W{
|
13
|
+
lib/**/*
|
14
|
+
spec/**/*
|
15
|
+
Gemfile
|
16
|
+
Rakefile
|
17
|
+
LICENSE*
|
18
|
+
RELEASE_NOTES*
|
19
|
+
README*
|
20
|
+
.gitignore
|
21
|
+
.document
|
22
|
+
.rspec
|
23
|
+
em-riak.gemspec
|
24
|
+
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
excludes = %W{
|
27
|
+
**/*.swp
|
28
|
+
**/#*
|
29
|
+
**/.#*
|
30
|
+
**/*~
|
31
|
+
**/*.rbc
|
32
|
+
**/.DS_Store
|
33
|
+
spec/support/test_server.yml
|
34
|
+
}
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
s.add_runtime_dependency "escape_utils"
|
37
|
+
s.add_runtime_dependency "yajl-ruby"
|
38
|
+
s.add_runtime_dependency "httpi"
|
39
|
+
s.add_runtime_dependency "eventmachine"
|
40
|
+
s.add_runtime_dependency "em-http-request"
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
files = includes.map {|glob| Dir[glob] }.flatten.select {|f| File.file?(f) }.sort
|
43
|
+
files.reject! {|f| excludes.any? {|e| File.fnmatch?(e, f) } }
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
s.files = files
|
46
|
+
s.require_paths = ['lib']
|
47
47
|
end
|