Class: Riak::MapReduce::Results Private
- Defined in:
- lib/riak/map_reduce/results.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Collects and normalizes results from MapReduce requests
Instance Method Summary collapse
-
#add(phase, result) ⇒ Object
private
Adds a new result to the collector.
-
#initialize(mr) ⇒ Results
constructor
private
Creates a new result collector.
-
#report ⇒ Array
private
Coalesces the query results.
Constructor Details
#initialize(mr) ⇒ Results
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new result collector
22 23 24 25 |
# File 'lib/riak/map_reduce/results.rb', line 22 def initialize(mr) @keep_count = mr.query.select {|p| p.keep }.size @hash = create_results_hash(mr.query) end |
Instance Method Details
#add(phase, result) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds a new result to the collector
30 31 32 |
# File 'lib/riak/map_reduce/results.rb', line 30 def add(phase, result) @hash[phase] += result end |
#report ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coalesces the query results
37 38 39 40 41 42 43 |
# File 'lib/riak/map_reduce/results.rb', line 37 def report if @keep_count > 1 @hash.to_a.sort.map {|(num, results)| results } else @hash[@hash.keys.first] end end |