Class: RiakRecord::Finder::ErlangEnhanced
- Inherits:
-
Basic
- Object
- Basic
- RiakRecord::Finder::ErlangEnhanced
show all
- Defined in:
- lib/riak_record/finder/erlang_enhanced.rb
Instance Method Summary
collapse
Methods inherited from Basic
#all, #any?, #count, #count_by, #each, #empty?, #find, #first, #initialize, #page, #to_a
Instance Method Details
#count_by_map_reduce(attribute, timeout = nil) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/riak_record/finder/erlang_enhanced.rb', line 13
def count_by_map_reduce(attribute, timeout = nil)
map_method, map_arg = map_method_for_attribute(attribute, "map_count_by_index", "map_count_by_value")
mr = Riak::MapReduce.new(@finder_class.client).
index(@bucket, @index, @value).
map(['riak_record_kv_mapreduce', map_method], :keep => false, :arg => [map_arg]).
reduce(['riak_record_kv_mapreduce', 'reduce_count_by'], :keep => true)
mr.timeout = timeout if timeout.present?
mr.run.first
end
|
#count_map_reduce(timeout = nil) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/riak_record/finder/erlang_enhanced.rb', line 23
def count_map_reduce(timeout = nil)
mr = Riak::MapReduce.new(@finder_class.client).
index(@bucket, @index, @value).
map(['riak_record_kv_mapreduce', 'map_count_found'], :keep => false).
reduce(['riak_kv_mapreduce','reduce_sum'], :keep => true)
mr.timeout = timeout if timeout.present?
mr.run.first
end
|
#pluck_by_map_reduce(attribute, timeout = nil) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/riak_record/finder/erlang_enhanced.rb', line 4
def pluck_by_map_reduce(attribute, timeout = nil)
map_method, map_arg = map_method_for_attribute(attribute, "map_pluck_index", "map_pluck_value")
mr = Riak::MapReduce.new(@finder_class.client).
index(@bucket, @index, @value).
map(['riak_record_kv_mapreduce', map_method], :keep => true, :arg => [map_arg])
mr.timeout = timeout if timeout.present?
mr.run
end
|