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
8 9 10 11 |
# File 'lib/riak/map_reduce/results.rb', line 8 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
16 17 18 |
# File 'lib/riak/map_reduce/results.rb', line 16 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
23 24 25 26 27 28 29 |
# File 'lib/riak/map_reduce/results.rb', line 23 def report if @keep_count > 1 @hash.to_a.sort.map {|(num, results)| results } else @hash[@hash.keys.first] end end |