riak-client 2.2.0.pre1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +0 -2
- data/README.markdown +11 -7
- data/RELEASE_NOTES.md +29 -2
- data/Rakefile +5 -3
- data/lib/riak/bucket.rb +55 -23
- data/lib/riak/bucket_properties.rb +8 -1
- data/lib/riak/bucket_type.rb +29 -0
- data/lib/riak/bucket_typed/bucket.rb +15 -7
- data/lib/riak/client.rb +24 -8
- data/lib/riak/client/beefcake/bucket_properties_operator.rb +8 -8
- data/lib/riak/client/beefcake/crdt/set_loader.rb +1 -1
- data/lib/riak/client/beefcake/crdt_loader.rb +1 -1
- data/lib/riak/client/beefcake/crdt_operator.rb +9 -9
- data/lib/riak/client/beefcake/message_codes.rb +4 -0
- data/lib/riak/client/beefcake/message_overlay.rb +4 -0
- data/lib/riak/client/beefcake/messages.rb +35 -5
- data/lib/riak/client/beefcake/object_methods.rb +21 -13
- data/lib/riak/client/beefcake/protocol.rb +7 -7
- data/lib/riak/client/beefcake/socket.rb +2 -2
- data/lib/riak/client/beefcake_protobuffs_backend.rb +58 -33
- data/lib/riak/client/protobuffs_backend.rb +5 -5
- data/lib/riak/client/yokozuna.rb +3 -3
- data/lib/riak/core_ext/deep_dup.rb +1 -1
- data/lib/riak/counter.rb +10 -10
- data/lib/riak/crdt/base.rb +39 -21
- data/lib/riak/crdt/batch_counter.rb +5 -5
- data/lib/riak/crdt/batch_map.rb +2 -2
- data/lib/riak/crdt/counter.rb +7 -7
- data/lib/riak/crdt/inner_counter.rb +4 -4
- data/lib/riak/crdt/inner_flag.rb +3 -3
- data/lib/riak/crdt/inner_map.rb +1 -1
- data/lib/riak/crdt/inner_register.rb +1 -1
- data/lib/riak/crdt/inner_set.rb +5 -5
- data/lib/riak/crdt/map.rb +9 -9
- data/lib/riak/crdt/set.rb +10 -10
- data/lib/riak/crdt/typed_collection.rb +39 -36
- data/lib/riak/errors/base.rb +1 -1
- data/lib/riak/errors/crdt_error.rb +20 -0
- data/lib/riak/errors/search_error.rb +6 -0
- data/lib/riak/index_collection.rb +1 -1
- data/lib/riak/link.rb +5 -3
- data/lib/riak/locale/en.yml +5 -1
- data/lib/riak/map_reduce.rb +7 -7
- data/lib/riak/map_reduce/filter_builder.rb +2 -2
- data/lib/riak/map_reduce/phase.rb +2 -2
- data/lib/riak/preflist_item.rb +7 -0
- data/lib/riak/rcontent.rb +8 -8
- data/lib/riak/robject.rb +27 -14
- data/lib/riak/search.rb +1 -0
- data/lib/riak/search/index.rb +17 -3
- data/lib/riak/search/query.rb +14 -6
- data/lib/riak/search/result_collection.rb +56 -3
- data/lib/riak/search/result_document.rb +71 -1
- data/lib/riak/search/schema.rb +6 -6
- data/lib/riak/secondary_index.rb +20 -12
- data/lib/riak/serializers.rb +0 -1
- data/lib/riak/util/escape.rb +2 -2
- data/lib/riak/util/translation.rb +1 -2
- data/lib/riak/version.rb +1 -1
- data/lib/riak/walk_spec.rb +67 -32
- data/riak-client.gemspec +5 -4
- data/spec/integration/riak/bucket_types_spec.rb +35 -5
- data/spec/integration/riak/conflict_resolution_spec.rb +1 -1
- data/spec/integration/riak/counters_spec.rb +1 -1
- data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
- data/spec/integration/riak/crdt_search_spec.rb +176 -0
- data/spec/integration/riak/crdt_spec.rb +9 -33
- data/spec/integration/riak/crdt_validation/map_spec.rb +4 -4
- data/spec/integration/riak/crdt_validation/set_spec.rb +13 -13
- data/spec/integration/riak/preflist_spec.rb +31 -0
- data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +2 -2
- data/spec/integration/riak/protobuffs_backends_spec.rb +9 -2
- data/spec/integration/riak/search_spec.rb +3 -3
- data/spec/integration/riak/secondary_index_spec.rb +3 -3
- data/spec/integration/riak/security_spec.rb +7 -7
- data/spec/integration/yokozuna/queries_spec.rb +1 -1
- data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +9 -9
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +9 -9
- data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +5 -5
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
- data/spec/riak/bucket_properties_spec.rb +27 -6
- data/spec/riak/bucket_spec.rb +5 -5
- data/spec/riak/bucket_type_spec.rb +21 -5
- data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
- data/spec/riak/client_spec.rb +36 -18
- data/spec/riak/counter_spec.rb +4 -4
- data/spec/riak/crdt/counter_spec.rb +2 -2
- data/spec/riak/crdt/inner_flag_spec.rb +2 -2
- data/spec/riak/crdt/inner_map_spec.rb +4 -4
- data/spec/riak/crdt/inner_register_spec.rb +1 -1
- data/spec/riak/crdt/map_spec.rb +4 -4
- data/spec/riak/crdt/shared_examples.rb +5 -5
- data/spec/riak/crdt/typed_collection_spec.rb +21 -21
- data/spec/riak/map_reduce/filter_builder_spec.rb +2 -2
- data/spec/riak/map_reduce/phase_spec.rb +4 -4
- data/spec/riak/map_reduce_spec.rb +60 -42
- data/spec/riak/multiget_spec.rb +2 -2
- data/spec/riak/robject_spec.rb +55 -14
- data/spec/riak/search/index_spec.rb +12 -2
- data/spec/riak/search/query_spec.rb +4 -4
- data/spec/riak/search/result_collection_spec.rb +6 -4
- data/spec/riak/search/result_document_spec.rb +52 -9
- data/spec/riak/search/schema_spec.rb +2 -2
- data/spec/riak/secondary_index_spec.rb +6 -6
- data/spec/riak/serializers_spec.rb +27 -10
- data/spec/riak/walk_spec_spec.rb +10 -6
- data/spec/spec_helper.rb +11 -2
- data/spec/support/crdt_search_config.rb +112 -0
- data/spec/support/crdt_search_fixtures.rb +42 -0
- data/spec/support/search_config.rb +7 -5
- data/spec/support/search_corpus_setup.rb +2 -2
- data/spec/support/test_client.rb +2 -2
- data/spec/support/unified_backend_examples.rb +5 -5
- data/spec/support/version_filter.rb +5 -3
- data/spec/support/wait_until.rb +9 -3
- metadata +36 -13
- data/spec/riak/bucket_typed/bucket.rb +0 -43
@@ -11,7 +11,7 @@ describe Riak::MapReduce::FilterBuilder do
|
|
11
11
|
it "adds filters to the list" do
|
12
12
|
subject.to_lower
|
13
13
|
subject.similar_to("ripple", 3)
|
14
|
-
expect(subject.to_a).to eq([[:to_lower],[:similar_to, "ripple", 3]])
|
14
|
+
expect(subject.to_a).to eq([[:to_lower], [:similar_to, "ripple", 3]])
|
15
15
|
end
|
16
16
|
|
17
17
|
it "adds a logical operation with a block" do
|
@@ -19,7 +19,7 @@ describe Riak::MapReduce::FilterBuilder do
|
|
19
19
|
starts_with "foo"
|
20
20
|
ends_with "bar"
|
21
21
|
end
|
22
|
-
expect(subject.to_a).to eq([[:or, [[:starts_with, "foo"],[:ends_with, "bar"]]]])
|
22
|
+
expect(subject.to_a).to eq([[:or, [[:starts_with, "foo"], [:ends_with, "bar"]]]])
|
23
23
|
end
|
24
24
|
|
25
25
|
it "raises an error on a filter arity mismatch" do
|
@@ -14,9 +14,9 @@ describe Riak::MapReduce::Phase do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "initializes with a type and an MF" do
|
17
|
-
phase = Riak::MapReduce::Phase.new(:type => :map, :function =>
|
17
|
+
phase = Riak::MapReduce::Phase.new(:type => :map, :function => %w(module function), :language => "erlang")
|
18
18
|
expect(phase.type).to eq(:map)
|
19
|
-
expect(phase.function).to eq(
|
19
|
+
expect(phase.function).to eq(%w(module function))
|
20
20
|
expect(phase.language).to eq("erlang")
|
21
21
|
end
|
22
22
|
|
@@ -28,7 +28,7 @@ describe Riak::MapReduce::Phase do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "assumes the language is erlang when the function is an array" do
|
31
|
-
phase = Riak::MapReduce::Phase.new(:type => :map, :function =>
|
31
|
+
phase = Riak::MapReduce::Phase.new(:type => :map, :function => %w(module function))
|
32
32
|
expect(phase.language).to eq("erlang")
|
33
33
|
end
|
34
34
|
|
@@ -100,7 +100,7 @@ describe Riak::MapReduce::Phase do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it "includes the module and function when invoking an Erlang function" do
|
103
|
-
@phase.function =
|
103
|
+
@phase.function = %w(riak_mapreduce mapreduce_fun)
|
104
104
|
expect(@phase.to_json).to include('"module":"riak_mapreduce"')
|
105
105
|
expect(@phase.to_json).to include('"function":"mapreduce_fun"')
|
106
106
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Riak::MapReduce do
|
4
|
-
|
4
|
+
|
5
5
|
let(:backend){ double 'Backend' }
|
6
6
|
let(:client) do
|
7
7
|
Riak::Client.new.tap do |c|
|
@@ -42,20 +42,20 @@ describe Riak::MapReduce do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "adds bucket/key pairs to the inputs" do
|
45
|
-
mr.add("foo","bar")
|
46
|
-
expect(mr.inputs).to eq([
|
45
|
+
mr.add("foo", "bar")
|
46
|
+
expect(mr.inputs).to eq([%w(foo bar)])
|
47
47
|
end
|
48
48
|
|
49
49
|
it "adds an array containing a bucket/key pair to the inputs" do
|
50
|
-
mr.add(
|
51
|
-
expect(mr.inputs).to eq([
|
50
|
+
mr.add(%w(foo bar))
|
51
|
+
expect(mr.inputs).to eq([%w(foo bar)])
|
52
52
|
end
|
53
53
|
|
54
54
|
it "adds an object to the inputs by its bucket and key" do
|
55
55
|
bucket = Riak::Bucket.new(client, "foo")
|
56
56
|
obj = Riak::RObject.new(bucket, "bar")
|
57
57
|
mr.add(obj)
|
58
|
-
expect(mr.inputs).to eq([
|
58
|
+
expect(mr.inputs).to eq([%w(foo bar)])
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'adds a bucket-typed object to the inputs' do
|
@@ -68,8 +68,8 @@ describe Riak::MapReduce do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "adds an array containing a bucket/key/key-data triple to the inputs" do
|
71
|
-
mr.add(["foo","bar",1000])
|
72
|
-
expect(mr.inputs).to eq([["foo","bar",1000]])
|
71
|
+
mr.add(["foo", "bar", 1000])
|
72
|
+
expect(mr.inputs).to eq([["foo", "bar", 1000]])
|
73
73
|
end
|
74
74
|
|
75
75
|
it "uses a bucket name as the single input" do
|
@@ -90,8 +90,14 @@ describe Riak::MapReduce do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "accepts a list of key-filters along with a bucket" do
|
93
|
-
mr.add("foo",
|
94
|
-
|
93
|
+
mr.add("foo",
|
94
|
+
[[:tokenize, "-", 3],
|
95
|
+
[:string_to_int],
|
96
|
+
[:between, 2009, 2010]])
|
97
|
+
expect(mr.inputs).to eq({bucket: "foo",
|
98
|
+
key_filters: [[:tokenize, "-", 3],
|
99
|
+
[:string_to_int],
|
100
|
+
[:between, 2009, 2010]]})
|
95
101
|
end
|
96
102
|
|
97
103
|
it 'accepts a list of key-filters along with a bucket-typed bucket' do
|
@@ -104,7 +110,7 @@ describe Riak::MapReduce do
|
|
104
110
|
mr.add(typed_bucket, filters)
|
105
111
|
|
106
112
|
expect(mr.inputs).to eq(
|
107
|
-
bucket: [typed_bucket.type.name,
|
113
|
+
bucket: [typed_bucket.type.name,
|
108
114
|
typed_bucket.name],
|
109
115
|
key_filters: filters
|
110
116
|
)
|
@@ -116,23 +122,35 @@ describe Riak::MapReduce do
|
|
116
122
|
string_to_int
|
117
123
|
between 2009, 2010
|
118
124
|
end
|
119
|
-
expect(mr.inputs).to eq(
|
125
|
+
expect(mr.inputs).to eq(bucket: "foo",
|
126
|
+
key_filters: [[:tokenize, "-", 3],
|
127
|
+
[:string_to_int],
|
128
|
+
[:between, 2009, 2010]])
|
120
129
|
end
|
121
130
|
|
122
131
|
context "using secondary indexes as inputs" do
|
123
132
|
it "sets the inputs for equality" do
|
124
133
|
expect(mr.index("foo", "email_bin", "sean@basho.com")).to eq(mr)
|
125
|
-
expect(mr.inputs).to eq(
|
134
|
+
expect(mr.inputs).to eq(bucket: "foo",
|
135
|
+
index: "email_bin",
|
136
|
+
key: "sean@basho.com")
|
126
137
|
end
|
127
138
|
|
128
139
|
it "sets the inputs for a range" do
|
129
140
|
expect(mr.index("foo", "rank_int", 10..20)).to eq(mr)
|
130
|
-
expect(mr.inputs).to eq(
|
141
|
+
expect(mr.inputs).to eq(bucket: "foo",
|
142
|
+
index: "rank_int",
|
143
|
+
start: 10,
|
144
|
+
end: 20)
|
131
145
|
end
|
132
146
|
|
133
147
|
it "raises an error when given an invalid query" do
|
134
|
-
expect
|
135
|
-
|
148
|
+
expect do
|
149
|
+
mr.index("foo", "rank_int", 1.0348)
|
150
|
+
end.to raise_error(ArgumentError)
|
151
|
+
expect do
|
152
|
+
mr.index("foo", "rank_int", Range.new(1.03, 1.05))
|
153
|
+
end.to raise_error(ArgumentError)
|
136
154
|
end
|
137
155
|
end
|
138
156
|
|
@@ -145,13 +163,13 @@ describe Riak::MapReduce do
|
|
145
163
|
after { Riak.url_decoding = @urldecode }
|
146
164
|
|
147
165
|
it "adds bucket/key pairs to the inputs with bucket and key escaped" do
|
148
|
-
mr.add("[foo]","(bar)")
|
149
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
|
166
|
+
mr.add("[foo]", "(bar)")
|
167
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
|
150
168
|
end
|
151
169
|
|
152
170
|
it "adds an escaped array containing a bucket/key pair to the inputs" do
|
153
|
-
mr.add(["[foo]","(bar)"])
|
154
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
|
171
|
+
mr.add(["[foo]", "(bar)"])
|
172
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
|
155
173
|
end
|
156
174
|
|
157
175
|
it "adds an object to the inputs by its escaped bucket and key" do
|
@@ -162,8 +180,8 @@ describe Riak::MapReduce do
|
|
162
180
|
end
|
163
181
|
|
164
182
|
it "adds an escaped array containing a bucket/key/key-data triple to the inputs" do
|
165
|
-
mr.add(["[foo]","(bar)","[]()"])
|
166
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
|
183
|
+
mr.add(["[foo]", "(bar)", "[]()"])
|
184
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29", "[]()"]])
|
167
185
|
end
|
168
186
|
|
169
187
|
it "uses an escaped bucket name as the single input" do
|
@@ -179,25 +197,25 @@ describe Riak::MapReduce do
|
|
179
197
|
after { Riak.url_decoding = @urldecode }
|
180
198
|
|
181
199
|
it "adds bucket/key pairs to the inputs with bucket and key unescaped" do
|
182
|
-
mr.add("[foo]","(bar)")
|
183
|
-
expect(mr.inputs).to eq([["[foo]","(bar)"]])
|
200
|
+
mr.add("[foo]", "(bar)")
|
201
|
+
expect(mr.inputs).to eq([["[foo]", "(bar)"]])
|
184
202
|
end
|
185
203
|
|
186
204
|
it "adds an unescaped array containing a bucket/key pair to the inputs" do
|
187
|
-
mr.add(["[foo]","(bar)"])
|
188
|
-
expect(mr.inputs).to eq([["[foo]","(bar)"]])
|
205
|
+
mr.add(["[foo]", "(bar)"])
|
206
|
+
expect(mr.inputs).to eq([["[foo]", "(bar)"]])
|
189
207
|
end
|
190
208
|
|
191
209
|
it "adds an object to the inputs by its unescaped bucket and key" do
|
192
210
|
bucket = Riak::Bucket.new(client, "[foo]")
|
193
211
|
obj = Riak::RObject.new(bucket, "(bar)")
|
194
212
|
mr.add(obj)
|
195
|
-
expect(mr.inputs).to eq([["[foo]","(bar)"]])
|
213
|
+
expect(mr.inputs).to eq([["[foo]", "(bar)"]])
|
196
214
|
end
|
197
215
|
|
198
216
|
it "adds an unescaped array containing a bucket/key/key-data triple to the inputs" do
|
199
|
-
mr.add(["[foo]","(bar)","[]()"])
|
200
|
-
expect(mr.inputs).to eq([["[foo]","(bar)","[]()"]])
|
217
|
+
mr.add(["[foo]", "(bar)", "[]()"])
|
218
|
+
expect(mr.inputs).to eq([["[foo]", "(bar)", "[]()"]])
|
201
219
|
end
|
202
220
|
|
203
221
|
it "uses an unescaped bucket name as the single input" do
|
@@ -214,13 +232,13 @@ describe Riak::MapReduce do
|
|
214
232
|
after { Riak.escaper = @oldesc }
|
215
233
|
|
216
234
|
it "adds bucket/key pairs to the inputs with bucket and key escaped" do
|
217
|
-
mr.add("[foo]","(bar)")
|
218
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
|
235
|
+
mr.add("[foo]", "(bar)")
|
236
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
|
219
237
|
end
|
220
238
|
|
221
239
|
it "adds an escaped array containing a bucket/key pair to the inputs" do
|
222
|
-
mr.add(["[foo]","(bar)"])
|
223
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
|
240
|
+
mr.add(["[foo]", "(bar)"])
|
241
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
|
224
242
|
end
|
225
243
|
|
226
244
|
it "adds an object to the inputs by its escaped bucket and key" do
|
@@ -231,8 +249,8 @@ describe Riak::MapReduce do
|
|
231
249
|
end
|
232
250
|
|
233
251
|
it "adds an escaped array containing a bucket/key/key-data triple to the inputs" do
|
234
|
-
mr.add(["[foo]","(bar)","[]()"])
|
235
|
-
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
|
252
|
+
mr.add(["[foo]", "(bar)", "[]()"])
|
253
|
+
expect(mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29", "[]()"]])
|
236
254
|
end
|
237
255
|
|
238
256
|
it "uses an escaped bucket name as the single input" do
|
@@ -284,19 +302,19 @@ describe Riak::MapReduce do
|
|
284
302
|
end
|
285
303
|
|
286
304
|
it "accepts a module/function pair" do
|
287
|
-
mr.send(type,
|
305
|
+
mr.send(type, %w(riak mapsomething))
|
288
306
|
expect(mr.query.size).to eq(1)
|
289
307
|
phase = mr.query.first
|
290
|
-
expect(phase.function).to eq(
|
308
|
+
expect(phase.function).to eq(%w(riak mapsomething))
|
291
309
|
expect(phase.type).to eq(type)
|
292
310
|
expect(phase.language).to eq("erlang")
|
293
311
|
end
|
294
312
|
|
295
313
|
it "accepts a module/function pair with extra options" do
|
296
|
-
mr.send(type,
|
314
|
+
mr.send(type, %w(riak mapsomething), :arg => [1000])
|
297
315
|
expect(mr.query.size).to eq(1)
|
298
316
|
phase = mr.query.first
|
299
|
-
expect(phase.function).to eq(
|
317
|
+
expect(phase.function).to eq(%w(riak mapsomething))
|
300
318
|
expect(phase.type).to eq(type)
|
301
319
|
expect(phase.language).to eq("erlang")
|
302
320
|
expect(phase.arg).to eq([1000])
|
@@ -356,7 +374,7 @@ describe Riak::MapReduce do
|
|
356
374
|
end
|
357
375
|
|
358
376
|
it "emits an array of inputs when there are multiple inputs" do
|
359
|
-
mr.add("foo","bar",1000).add("foo","baz")
|
377
|
+
mr.add("foo", "bar", 1000).add("foo", "baz")
|
360
378
|
expect(mr.to_json).to include('"inputs":[["foo","bar",1000],["foo","baz"]]')
|
361
379
|
end
|
362
380
|
|
@@ -372,7 +390,7 @@ describe Riak::MapReduce do
|
|
372
390
|
|
373
391
|
describe "executing the map reduce job" do
|
374
392
|
before :each do
|
375
|
-
mr.map("Riak.mapValues"
|
393
|
+
mr.map("Riak.mapValues", :keep => true)
|
376
394
|
end
|
377
395
|
|
378
396
|
it "submits the query to the backend" do
|
@@ -384,7 +402,7 @@ describe Riak::MapReduce do
|
|
384
402
|
arr = []
|
385
403
|
expect(backend).to receive(:mapred).with(mr).and_yield("foo").and_yield("bar")
|
386
404
|
mr.run {|v| arr << v }
|
387
|
-
expect(arr).to eq(
|
405
|
+
expect(arr).to eq(%w(foo bar))
|
388
406
|
end
|
389
407
|
|
390
408
|
it "interprets failed requests with JSON content-types as map reduce errors" do
|
data/spec/riak/multiget_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe Riak::Multiget do
|
|
42
42
|
|
43
43
|
expect(@multiget.finished?).to be_falsey
|
44
44
|
|
45
|
-
# allow fetch
|
45
|
+
# allow fetch
|
46
46
|
@slow_mtx.unlock
|
47
47
|
|
48
48
|
@results = @multiget.results
|
@@ -70,7 +70,7 @@ describe Riak::Multiget do
|
|
70
70
|
it "returns a hash of pairs to values" do
|
71
71
|
expect(@bucket).to receive(:[]).with('key1')
|
72
72
|
expect(@bucket).to receive(:[]).with('key2')
|
73
|
-
|
73
|
+
|
74
74
|
@multiget = Riak::Multiget.new(@client, @pairs)
|
75
75
|
@multiget.fetch
|
76
76
|
@results = @multiget.results
|
data/spec/riak/robject_spec.rb
CHANGED
@@ -147,13 +147,13 @@ describe Riak::RObject do
|
|
147
147
|
"vclock"=> "a85hYGBgzmDKBVIsCfs+fc9gSN9wlA8q/hKosDpIOAsA",
|
148
148
|
"values"=> [
|
149
149
|
{"metadata"=>
|
150
|
-
{"Links"=>[
|
150
|
+
{"Links"=>[%w(addresses A2cbUQ2KEMbeyWGtdz97LoTi1DN home_address)],
|
151
151
|
"X-Riak-VTag"=>"5bnavU3rrubcxLI8EvFXhB",
|
152
152
|
"content-type"=>"application/json",
|
153
153
|
"X-Riak-Last-Modified"=>"Mon, 12 Jul 2010 21:37:43 GMT",
|
154
154
|
"X-Riak-Meta"=>{"X-Riak-Meta-King-Of-Robots"=>"I"},
|
155
155
|
"index" => {
|
156
|
-
"email_bin" => ["sean@basho.com","seancribbs@gmail.com"],
|
156
|
+
"email_bin" => ["sean@basho.com", "seancribbs@gmail.com"],
|
157
157
|
"rank_int" => 50
|
158
158
|
}
|
159
159
|
},
|
@@ -163,7 +163,7 @@ describe Riak::RObject do
|
|
163
163
|
]
|
164
164
|
}
|
165
165
|
]
|
166
|
-
@object = Riak::RObject.load_from_mapreduce(@client
|
166
|
+
@object = Riak::RObject.load_from_mapreduce(@client, @sample_response).first
|
167
167
|
expect(@object).to be_kind_of(Riak::RObject)
|
168
168
|
end
|
169
169
|
|
@@ -181,6 +181,7 @@ describe Riak::RObject do
|
|
181
181
|
|
182
182
|
it "sets the vclock" do
|
183
183
|
expect(@object.vclock).to eq("a85hYGBgzmDKBVIsCfs+fc9gSN9wlA8q/hKosDpIOAsA")
|
184
|
+
expect(@object.causal_context).to eq @object.vclock
|
184
185
|
end
|
185
186
|
|
186
187
|
it "loads and parse links" do
|
@@ -274,17 +275,31 @@ describe Riak::RObject do
|
|
274
275
|
end
|
275
276
|
|
276
277
|
it "raises an error when the content_type is blank" do
|
277
|
-
expect
|
278
|
-
|
278
|
+
expect do
|
279
|
+
@object.content_type = nil
|
280
|
+
@object.store
|
281
|
+
end.to raise_error(ArgumentError)
|
282
|
+
expect do
|
283
|
+
@object.content_type = ' '
|
284
|
+
@object.store
|
285
|
+
end.to raise_error(ArgumentError)
|
279
286
|
end
|
280
287
|
|
281
288
|
it "raises an error when given an empty string as key" do
|
282
|
-
expect
|
289
|
+
expect do
|
290
|
+
@object.key = ''
|
291
|
+
@object.store
|
292
|
+
end.to raise_error(ArgumentError)
|
283
293
|
end
|
284
294
|
|
285
295
|
it "passes quorum parameters and returnbody to the backend" do
|
286
|
-
expect(@backend).to receive(:store_object).
|
287
|
-
|
296
|
+
expect(@backend).to receive(:store_object).
|
297
|
+
with(@object,
|
298
|
+
returnbody: false,
|
299
|
+
w: 3,
|
300
|
+
dw: 2).
|
301
|
+
and_return(true)
|
302
|
+
@object.store(returnbody: false, w: 3, dw: 2)
|
288
303
|
end
|
289
304
|
|
290
305
|
it "raises an error if the object is in conflict" do
|
@@ -393,7 +408,9 @@ describe Riak::RObject do
|
|
393
408
|
object.raw_data = { 'a' => 7 }
|
394
409
|
object.content_type = 'inspect/type'
|
395
410
|
Riak::Serializers['inspect/type'] = Object.new.tap do |o|
|
396
|
-
def o.load(object)
|
411
|
+
def o.load(object)
|
412
|
+
"serialize for inspect"
|
413
|
+
end
|
397
414
|
end
|
398
415
|
|
399
416
|
expect(object.inspect).to match(/serialize for inspect/)
|
@@ -412,13 +429,37 @@ describe Riak::RObject do
|
|
412
429
|
end
|
413
430
|
|
414
431
|
describe '#attempt_conflict_resolution' do
|
415
|
-
let(:conflicted_robject)
|
432
|
+
let(:conflicted_robject) do
|
433
|
+
Riak::RObject.new(@bucket, "conflicted") do |r|
|
434
|
+
r.siblings = [ Riak::RContent.new(r), Riak::RContent.new(r)]
|
435
|
+
end
|
436
|
+
end
|
416
437
|
let(:resolved_robject) { Riak::RObject.new(@bucket, "resolved") }
|
417
438
|
let(:invoked_resolvers) { [] }
|
418
|
-
let(:resolver_1)
|
419
|
-
|
420
|
-
|
421
|
-
|
439
|
+
let(:resolver_1) do
|
440
|
+
lambda do |r|
|
441
|
+
invoked_resolvers << :resolver_1
|
442
|
+
nil
|
443
|
+
end
|
444
|
+
end
|
445
|
+
let(:resolver_2) do
|
446
|
+
lambda do |r|
|
447
|
+
invoked_resolvers << :resolver_2
|
448
|
+
:not_an_robject
|
449
|
+
end
|
450
|
+
end
|
451
|
+
let(:resolver_3) do
|
452
|
+
lambda do |r|
|
453
|
+
invoked_resolvers << :resolver_3
|
454
|
+
r
|
455
|
+
end
|
456
|
+
end
|
457
|
+
let(:resolver_4) do
|
458
|
+
lambda do |r|
|
459
|
+
invoked_resolvers << :resolver_4
|
460
|
+
resolved_robject
|
461
|
+
end
|
462
|
+
end
|
422
463
|
|
423
464
|
before(:each) do
|
424
465
|
described_class.on_conflict(&resolver_1)
|
@@ -42,7 +42,7 @@ describe Riak::Search::Index do
|
|
42
42
|
and_raise(Riak::ProtobuffsFailedRequest.new(:not_found, 'not found'))
|
43
43
|
|
44
44
|
expect(backend).to receive(:create_search_index).
|
45
|
-
with(index_name, nil, nil)
|
45
|
+
with(index_name, nil, nil, nil)
|
46
46
|
|
47
47
|
expect{ subject.create! }.to_not raise_error
|
48
48
|
end
|
@@ -50,9 +50,19 @@ describe Riak::Search::Index do
|
|
50
50
|
it 'raises an error when creating an index that already exists' do
|
51
51
|
index_exists_expectation
|
52
52
|
|
53
|
-
expect{ subject.create! }.
|
53
|
+
expect{ subject.create! }.
|
54
|
+
to raise_error(Riak::SearchError::IndexExistsError)
|
54
55
|
end
|
55
56
|
|
57
|
+
it "spawns a query" do
|
58
|
+
t = "some query term"
|
59
|
+
expect(subject).to receive(:exists?).and_return(true)
|
60
|
+
expect(query = subject.query(t)).to be_a Riak::Search::Query
|
61
|
+
expect(query.term).to eq t
|
62
|
+
expect(query.index).to eq subject
|
63
|
+
expect(query.client).to eq subject.client
|
64
|
+
end
|
65
|
+
|
56
66
|
it 'returns data about the index' do
|
57
67
|
index_exists_expectation
|
58
68
|
|