Class: Droonga::Plugins::Search::ReduceCollector
Instance Method Summary
collapse
Methods inherited from Collector
#initialize, message
#find_sub_classes, #options
Instance Method Details
#collect(message) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/droonga/plugins/search.rb', line 142
def collect(message)
if message.name == "errors"
basic_reduce_collector = Basic::ReduceCollector.new
return basic_reduce_collector.collect(message)
end
message.input.each do |output_name, elements|
old_value = message.values[output_name]
if old_value
value = reduce_elements(elements, old_value, message.value)
else
value = message.value
end
message.values[output_name] = value
end
end
|
#reduce_elements(elements, left_values, right_values) ⇒ Object
160
161
162
163
164
165
166
167
|
# File 'lib/droonga/plugins/search.rb', line 160
def reduce_elements(elements, left_values, right_values)
result = {}
elements.each do |key, deal|
reducer = Reducer.new(deal)
result[key] = reducer.reduce(left_values[key], right_values[key])
end
result
end
|