riak-record 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe5a757a4b15f3c615b49c01dfb9d72bac344359
4
- data.tar.gz: 5a713dae30be0c3946251dd913257b21b6e12f5f
3
+ metadata.gz: 4634d0a8658d10c47899dd710c7952d6d129e1f2
4
+ data.tar.gz: 51df5cf9ca86b4aa9aec46c8213111642b9f0d36
5
5
  SHA512:
6
- metadata.gz: 27efbc9af07e592abe8bc5d25139003b1ca094de54c184f24ccabdfc82dbe9becf9700c226855a0bf7cdae3b09038397dbdc461485dc6f7dd098457fd3bc3663
7
- data.tar.gz: b9953a8f21cb738f4fa0df3606ddaa1ac209dbe703cad47f1ec4d5c27aa96d3be4b6c0ee74b20dd3b649861f5e18c99305318ed83aca29e86aee5a394ff2a78b
6
+ metadata.gz: 32b6c185d2bcc27ff1fd6cebd9097d31df3a1cce646f66b80ea59066e338cec8437e6249750b235b16f888cb61fa3ccf400bccba213866e78d6cc24a925a0193
7
+ data.tar.gz: 09cdc00d887a3c22fa6b8265f4f80bb03affea55a4f3b4a1059f3bf6d7975d7769e76c9ce8c8c2d1d85a64178fc691f1060919ed58a540614ce04624e69f96c9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -132,9 +132,8 @@ module RiakRecord
132
132
  finder.first(n)
133
133
  end
134
134
 
135
- # TODO: this is broke
136
- def self.page(page_number = 1, page_size = 100)
137
- finder.page(page_number, page_size)
135
+ def self.page(continuation = nil, page_size = nil)
136
+ finder.page(continuation, page_size)
138
137
  end
139
138
 
140
139
  def self.data_attributes(*attributes)
@@ -182,7 +181,7 @@ module RiakRecord
182
181
  end
183
182
 
184
183
  def self.where(options)
185
- RiakRecord::Finder::Basic.new(self, options)
184
+ finder_class.new(self, options)
186
185
  end
187
186
 
188
187
  def self.find(key_or_keys)
@@ -109,13 +109,7 @@ module Finder
109
109
  mr.run
110
110
  end
111
111
 
112
- private
113
-
114
- def load_started?
115
- @load_complete || @loaded_objects.count > 0
116
- end
117
-
118
- def count_by_map_reduce(attribute)
112
+ def count_by_map_reduce(attribute, timeout = nil)
119
113
  count_by_index = @finder_class.index_names[attribute.to_sym].present?
120
114
  parsed_attribute = count_by_index ? "v.values[0].metadata.index.#{@finder_class.index_names[attribute.to_sym]}" : "JSON.parse(v.values[0].data).#{attribute}"
121
115
  Riak::MapReduce.new(@finder_class.client).
@@ -124,13 +118,20 @@ module Finder
124
118
  reduce("function(values) { var result = {}; for (var value in values) { for (var key in values[value]) { if (key in result) { result[key] += values[value][key]; } else { result[key] = values[value][key]; }}} return [result]; }", :keep => true).run.first
125
119
  end
126
120
 
127
- def count_map_reduce
121
+ def count_map_reduce(timeout = nil)
128
122
  Riak::MapReduce.new(@finder_class.client).
129
123
  index(@bucket, @index, @value).
130
124
  map("function(v){ return [1] }", :keep => false).
131
125
  reduce(['riak_kv_mapreduce','reduce_sum'], :keep => true).run.first
132
126
  end
133
127
 
128
+
129
+ private
130
+
131
+ def load_started?
132
+ @load_complete || @loaded_objects.count > 0
133
+ end
134
+
134
135
  def load_next_page(page_size = @page_size)
135
136
  return if @load_complete
136
137
  if @querier
@@ -1,38 +1,44 @@
1
1
  module RiakRecord
2
2
  class Finder::ErlangEnhanced < Finder::Basic
3
3
 
4
- def pluck_by_map_reduce(attribute, timeout = nil)
5
- map_method, map_arg = map_method_for_attribute(attribute, "map_pluck_index", "map_pluck_value")
6
- mr = Riak::MapReduce.new(@finder_class.client).
7
- index(@bucket, @index, @value).
8
- map(['riak_record_kv_mapreduce', map_method], :keep => true, :arg => [map_arg])
9
- mr.timeout = timeout if timeout.present?
10
- mr.run
11
- end
4
+ def pluck_by_map_reduce(attribute, timeout = nil)
5
+ map_method, map_arg = map_method_for_attribute(attribute, "map_pluck_index", "map_pluck_value")
6
+ mr = Riak::MapReduce.new(@finder_class.client).
7
+ index(@bucket, @index, @value).
8
+ map(['riak_record_kv_mapreduce', map_method], :keep => true, :arg => [map_arg])
9
+ mr.timeout = timeout if timeout.present?
10
+ mr.run
11
+ end
12
12
 
13
- private
13
+ def count_by_map_reduce(attribute, timeout = nil)
14
+ map_method, map_arg = map_method_for_attribute(attribute, "map_count_by_index", "map_count_by_value")
15
+ mr = Riak::MapReduce.new(@finder_class.client).
16
+ index(@bucket, @index, @value).
17
+ map(['riak_record_kv_mapreduce', map_method], :keep => false, :arg => [map_arg]).
18
+ reduce(['riak_record_kv_mapreduce', 'reduce_count_by'], :keep => true)
19
+ mr.timeout = timeout if timeout.present?
20
+ mr.run.first
21
+ end
22
+
23
+ def count_map_reduce(timeout = nil)
24
+ mr = Riak::MapReduce.new(@finder_class.client).
25
+ index(@bucket, @index, @value).
26
+ map(['riak_record_kv_mapreduce', 'map_count_found'], :keep => false).
27
+ reduce(['riak_kv_mapreduce','reduce_sum'], :keep => true)
28
+ mr.timeout = timeout if timeout.present?
29
+ mr.run.first
30
+ end
14
31
 
15
- def map_method_for_attribute(attribute, index_method, value_method)
16
- count_by_index = @finder_class.index_names[attribute.to_sym].present?
17
- map_method = count_by_index ? index_method : value_method
18
- map_arg = count_by_index ? @finder_class.index_names[attribute.to_sym] : attribute
19
- [map_method, map_arg]
20
- end
21
32
 
22
- def count_by_map_reduce(attribute)
23
- map_method, map_arg = map_method_for_attribute(attribute, "map_count_by_index", "map_count_by_value")
24
- Riak::MapReduce.new(@finder_class.client).
25
- index(@bucket, @index, @value).
26
- map(['riak_record_kv_mapreduce', map_method], :keep => false, :arg => [map_arg]).
27
- reduce(['riak_record_kv_mapreduce', 'reduce_count_by'], :keep => true).run.first
33
+ private
34
+
35
+ def map_method_for_attribute(attribute, index_method, value_method)
36
+ count_by_index = @finder_class.index_names[attribute.to_sym].present?
37
+ map_method = count_by_index ? index_method : value_method
38
+ map_arg = count_by_index ? @finder_class.index_names[attribute.to_sym] : attribute
39
+ [map_method, map_arg]
28
40
  end
29
- end
30
41
 
31
- def count_map_reduce
32
- Riak::MapReduce.new(@finder_class.client).
33
- index(@bucket, @index, @value).
34
- map(['riak_record_kv_mapreduce', 'map_count_found'], :keep => false).
35
- reduce(['riak_kv_mapreduce','reduce_sum'], :keep => true).run.first
36
42
  end
37
43
 
38
44
  end
data/riak-record.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: riak-record 0.7.1 ruby lib
5
+ # stub: riak-record 0.7.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "riak-record"
9
- s.version = "0.7.1"
9
+ s.version = "0.7.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Graff