class RiakRecord::Finder::ErlangEnhanced
Public Instance Methods
count_by_map_reduce(attribute, timeout = nil)
click to toggle source
# File lib/riak_record/finder/erlang_enhanced.rb, line 11 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 = new_map_reduce. 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)
click to toggle source
# File lib/riak_record/finder/erlang_enhanced.rb, line 20 def count_map_reduce(timeout = nil) mr = new_map_reduce. 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)
click to toggle source
# 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 = new_map_reduce.map(['riak_record_kv_mapreduce', map_method], :keep => true, :arg => [map_arg]) mr.timeout = timeout if timeout.present? mr.run end
Private Instance Methods
map_method_for_attribute(attribute, index_method, value_method)
click to toggle source
# File lib/riak_record/finder/erlang_enhanced.rb, line 31 def map_method_for_attribute(attribute, index_method, value_method) count_by_index = @finder_class.index_names[attribute.to_sym].present? map_method = count_by_index ? index_method : value_method map_arg = count_by_index ? @finder_class.index_names[attribute.to_sym] : attribute [map_method, map_arg] end